Why is database considered the best place to apply conditional logic?

Posted on 2007-07-27
Last Modified: 2008-03-06
Why is database considered the best place to apply conditional logic?
Question by:d2marcelo
    1 Comment
    LVL 45

    Accepted Solution

    The database can process the query, returning exactly the data needed without imposing that logic into a program or putting unnecessary data on a network.

    Imagine a table with 1,000,000 row and your query needs the row with an ID value of 712.  The database can find a single row and return it simply by placing the clause WHERE id=712 on the query.  This may well be an index scan and if the required data is in the index, it's not even necessary to read the data row.

    By contrast, if the logic were put into a program, it would have to read all 1,000,000 rows, discarding the data it doesn't want.

    Pushing logic down to as low a level as possible is usually a good idea.

    Good Luck,

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
    From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
    This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
    This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now