Re: Multiple rows for one column in a MySQL table?
| From: | JJeffman | Date: | Tue, 27 Mar 2001 23:06:37 +0000 |
| Subject: | Re: Multiple rows for one column in a MySQL table? | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-7913@lists.php.net to get a copy of this message | ||
You haven't to repeat the name field in the telephone numbers table. This
table needs another primary key which is not "id".
"id" is the foreign key that allow you to have a one to many relationship.
It can be (IMHO):
Client table:
CLIENT_ID NAME
FoneNumber table:
FONE_ID FONENUMBER CLIENT_ID
HTH
Jayme.
-----Mensagem Original-----
De: Peter J. Krawetzky <krawetzky1@earthlink.net>
Para: Cal Evans <cal@calevans.com>; <php-db@lists.php.net>
Enviada em: terça-feira, 27 de março de 2001 14:55
Assunto: Re: [PHP-DB] Multiple rows for one column in a MySQL table?
> Even if you normalize your database design, you must still tell it who
owns
> the row. For example, you have a table containing the following columns:
> id name
>
> You have another table that contains the phone numbers:
> id name phone number
>
> In order to connect the rows via a foreign key, you must have the
> information in the first table and again in the second table.
Normalization
> only seperates repetative data. If you didn't normalize, your first table
> would look something like this:
> id name phone number 1 phone number 2 phone number 3 (etc,
> etc, etc).
>