问题
Suppose i have a table with 3 fields
Person_id, Name and address. Now the problem is that a person can have multiple addresses. and the principle of atomic values says that data should be atomic.
So then how am i suppose to store multiple addresses for a single person ?
回答1:
You're supposed to create an ADDRESS
table that has a foreign key linking it to a PERSON
record, i.e. PERSON_ID
. This is the "relational" component of a relational database, and it's why it's more flexible than a flat file (which is like a single table).
回答2:
Put adresses in a second table, give each adress a "Person ID", so that mutiple rows in the adress-table can referr to on person.
回答3:
I would suggest adding a address type to the address table to identify which type of address it is (Home, Vacation, Office), etc. Something like: AddType that refers to a list table where more types could be added down the road.
来源:https://stackoverflow.com/questions/10572987/storing-multiple-values-for-a-single-field-in-a-database