Saving multiple values ​​for one field in the database

Suppose I have a table with three 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 how can I store multiple addresses for one person?

+4
source share
3 answers

It is supposed to create an ADDRESS table with a foreign key that associates it with the PERSON record, i.e. PERSON_ID . This is a "relational" component of a relational database, and why it is more flexible than a flat file (which looks like a single table).

+11
source

Put the addresses in the second table, give each address an "Identity ID" so that several lines in the table can refer to the address table.

0
source

I would suggest adding an address type to the address table to determine which address type (Home, Vacation, Office), etc. Something like: AddType, which refers to a list table to which you can add more types to the road.

0
source

Source: https://habr.com/ru/post/1412263/


All Articles