also, LEFT OUTER JOIN and COALESCE are standard sql, so no worries if you switch to oracle
Well, since you are diving into SQL, please allow me to describe what I need to do again...
When a Member uploads a Photo, I store the physical Photo in a directory on my webserver, and in my database I have the fields "photo_name" and "photo_approved" (default=0).
Usually when I grab a Photo, I need to grab other Member Info and would have something like...
SELECT username, online_status, photo_name, photo_label, first_name, location
So, in SQL, how would I say...
"When you query the database for DoubleDee's info (id=19), check to see if "photo_approved"==TRUE, and if it is, then return the "photo_name", otherwise return "photo_pending_review.jpg" so a dummy photo can be shown."
I have a PHP Function that does that, but the problem is I query the database once - like in the example above - and then I have to run a SELECT a second time in my PHP Function to do the search and conditional I just described. So you have 2 database hits for only 1 bang?!
where would you store the business logic that an order has to be associated with a known customer (relational integrity, enforced by foreign key)
where would you store the business logic that a customer needs to be identified uniquely (entity integrity, enforced by primary key)
and the toughest question of all... where would you store the business logic that a product must have certain known attributes (tables with defined columns for specific items of data)
anybody that thinks you should do "all" business logic in the application (php) is fooling themselves, and you can verify this by taking the database away from them and telling them to implement with text files and excel sheets
as for the database being a "bottleneck" you might ask yourself which types of people encounter more bottlenecks -- developers who know what they're doing or developers who are, shall we say, uninformed about what business rules actually belong in the database
Well, I'm sure that is a complicated topic, and one no one can address without a specific problem, but I have heard that consistently over the years, making me at least conclude that database calls are expensive, so query wisely...
sorry, this sounded like a rant, didn't it
wasn't aimed at you, debbie
Oh, I know. And the 20-something year old punk, who has both enough naiveté and arrogance to fill up Texas makes me shake my head...
For my simple case, I think using the database or a PHP Function is about equal.
But I am on an eternal quest to learn how to do things multiple ways, and learn how to do things the best way possible, so that is why I am asking.