Re: novice on table design
| From: | Tony S. Wu | Date: | Sat, 14 May 2005 05:09:27 +0000 |
| Subject: | Re: novice on table design | ||
| References: | 1 2 3 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-39438@lists.php.net to get a copy of this message | ||
actually, no, Shop, Employee, and Customer are not distinct.
in your instance they are the same type of entry.
don't distinguish them by tables, rather use a column to hold some sort of an ID for each type.
of course you'll end up with a table with many columns, and many of them will be null depending on which type an entry is.
but with this approach, you can easily associate with an address table.
Tony S. Wu
tonyswu@mac.com
On May 14, 2005, at 4:49 AM, tony yau wrote:
Hi Miguel,Thanks for the reply.the non-customer is actually a Shop, so Employee, Customer and Shop are distinct enough to have their own tables. Now they all have an Address, and the problem is how do I allow multiple addresses for each these 'people'(without using a lookup table) tony. "Miguel Guirao" <miguel.guirao@mail.telcel.com> wrote in message news:GFEHIFBDMNHCPDFHEJDGEEOOCDAA.miguel.guirao@mail.telcel.com...The schema of your table is wrong, is you do bnormalize it you will findoutthat you need two tables for this approach. One table for your people and another one for the n addresses of your people. If you keep your current schema, you will have as many rows for one person as many addresses for that person you have, and you will be duplicatingmanyfields. So you must split your tables, one for your people and another for your people's addresses. -----Original Message----- From: tony yau [mailto:tony.yau@emigen.co.uk] Sent: Viernes, 13 de Mayo de 2005 09:27 a.m. To: php-db@lists.php.net Subject: [PHP-DB] novice on table design Hi all, I have the following tablesAddressEmployee Customer non-Customeradded========== ========== ============= ========== pkey pkey pkeypkeynumber type type...payrate grant capitalI need to allow the three types of people to have n addresses, so I'vea type to distinguish the 3 types of people and their respective pkey onto address table.cons.Address=========pkey ... type (either Employee, Customer or non-Customer etc) fkey (the pkey of Employee, Customer or non-Customer etc)I know this design looks awkward but it does have the advantage of having less tables otherwise. BUT somehow it doesn't feel right. Can someone points me its pros andthanks all. Tony Yau -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php