[nycphp-talk] data modelling vs. db design (was: ER Diagram toolfor MySQL/OS X)
Kenneth Downs
ken at secdat.com
Fri Oct 7 15:00:07 EDT 2005
> Kenneth Downs wrote:
>> The resolution uses the magic of NULLs and COALESCE to join the tables
>> together and pull out the price.
>>
>> select coalesce(special.price,item.price,cat.price)
>> from SPECIALS special
>> JOIN ITEMS item
>> JOIN CATEGORIES cat blah blah blah
>
> Good idea, though shouldn't the SQL be something more like:
>
> SELECT coalesce(special.price,item.price,cat.price)
> FROM CATEGORIES cat
> LEFT JOIN ITEMS item ON item.cat_id=cat.cat_id
> LEFT JOIN SPECIALS special ON special.item_id=item.item_id
> WHERE blah blah blah
yup.
>
> Dan
>
>>
>>> -----Original Message-----
>>> From: talk-bounces at lists.nyphp.org
>>> [mailto:talk-bounces at lists.nyphp.org]
>>> On Behalf Of Stephen Musgrave
>>> Sent: Friday, October 07, 2005 1:49 PM
>>> To: NYPHP Talk
>>> Subject: Re: [nycphp-talk] data modelling vs. db design (was: ER Diagram
>>> toolfor MySQL/OS X)
>>>
>>>
>>>
>>>> BTW, in the world of business objects, even the concept of a User
>>>> needs to
>>>> be rethought. I would do away with Users as a fundamental business
>>>> object
>>>> and replace it with the more generic Person, and identify system Users
>>>> as a
>>>> subset of the Person universe. Users then become Persons who play the
>>>> Role,
>>>> System User, in which additional sets of information are required such
>>>> as
>>>> username, password, permissions, et cetera.
>>> A-ha! Even more normalization. This is the way I have done it my
>>> system, btw. There are "staff" users ... err PEOPLE".. and
>>> "participants" which have their own tables and then the USER table
>>> handles data that is required for those people to use the application.
>>>
>>> Thanks for all the contributions to the thread - it has been very
>>> helpful!
> _______________________________________________
> New York PHP Talk Mailing List
> AMP Technology
> Supporting Apache, MySQL and PHP
> http://lists.nyphp.org/mailman/listinfo/talk
> http://www.nyphp.org
>
--
Kenneth Downs
Secure Data Software
631-379-0010
ken at secdat.com
PO Box 708
East Setauket, NY 11733
More information about the talk
mailing list