Anuvrat Parashar
Anuvrat Parashar

Reputation: 3120

How to store multivalued attributes in a database?

For example storing the different phone numbers that a person might be contacted on. If I do not want my database to be restricted to allow fixed, say 6, numbers per person then the only solution to the problem seems to be to have a separate table and have multiple records for one person. eg

person1, p1number1
person1, p1number2
person2, p2number1
person1, p1number3
.
.
.
...

and so no. But in a practical scenario this kind of table might become very large. So is this approach better or one should not be thinking of storing multivalued attributes in an RDBMS at all?

Upvotes: 1

Views: 700

Answers (2)

dbrin
dbrin

Reputation: 15673

You can always fall back to comma separated values if you don't like separate table.

Upvotes: 0

dwerner
dwerner

Reputation: 6602

This is perfectly normal; breaking out a new table is better than adding innumerable fields to an existing one, IMO. Normally this is done with an FK pointing at person_id, say. Practically speaking, these tables tend not to actually get THAT large.

It's just more work.

Upvotes: 1

Related Questions