Database relation one to one based on type -
i have following tables:
- user : id, typeid ..
- type: id, name ..
based on type user has between 1 3 values. example user 1 typ b, , type b has 3 values. type have 2 values. create different value-tables
- valuesa: id, min-value, max-value, userid
- valuesb: id, value1, value2, value3, userid ...
and use userid foreign key, , decide table should use based on type. or create 1 value-table value-fields , leave empty fields in rows, , add valueid users table? or better way this?
the better way normalize value rows.
value ----- user id type id sequence value
the primary key table (user id, type id, sequence). sequence column makes primary key unique. type a, sequence 1 , 2. type b, sequence 1, 2, , 3.
this design allows flexibility have 0 values, 5 values, or 150 values given user , type.
Comments
Post a Comment