Sunday, 15 May 2011

sql - Table with set of 3 columns maximum which have same meaning -



sql - Table with set of 3 columns maximum which have same meaning -

i have table person have maximum 3 opinion , each rows of person have different opinion, in other word never find 2 person have same opinion, there no many-to-many relationship between person , opinion.

i never check opinion validation no 2 person have same opinion, it's information.

the question :

should create 1 table

person ( #id_person , ... , opinion1 , opinion2 , opinion3 , ... )

or add together new table :

person ( #id_person , ... ) opinions ( #id_opinion , sentiment , *id_person* ) // id_person fk

for me don't want create new table opinions because have no meaning add together new rows much have new person

also if grouping them in 1 table , have 1 opinion there problem of waste of space ? if declare opinion varchar ?

and if create new table opinions need primary pseudo-key id_opinion ?

a opinion can varchar(50).

i recommend 2 tables. first table persons table. have personid , sorts of other info person.

the sec table personopinions table. have 1 row per opinion, info such as:

personid opinion date , time of opinion topic of sentiment (if appropriate) method inputing sentiment (if appropriate)

from say, there no need separate opinions table, because sentiment "unique". however, want store opinions in separate table, separate row per opinion.

you can utilize trigger enforce constraint person has 3 opinions. if decide alter in future, easy two-table solution.

sql database database-design

No comments:

Post a Comment