0

I need an advice. I have some issue with modeling the database in SQL Server. Let's say I want to create a cars database. There are various type of engine like fuel, electric, hybrid. Every type has some specifications. But not the same (not the same columns in the table).

I have these tables (suppose all relations are 1:n)

Cars

ID (p.key)
ID_type (f.key)

Type

ID (p.key)
Name
ID_properties (f.key)

Properties

ID (p.key)
Value x
Value y
Value z
ID_contact (f.key)

Contact

ID (p.key)
name
Tel
Email

My problem is that every type has different columns in table properties so I think I need the special properties table for every type of the car, or another model. But I don't know exactly how to do it.

Can you please help me? (I appreciate some advice if this is a good solution).

Thank you very much.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Serv0
  • 181
  • 1
  • 7
  • 17

1 Answers1

0

you may add one table to for Property Fields Define, add another one to store the Property Field value:

PropertyFieldDefine
code
name
type(sting\date time\num)

PropertyField
ID(p.key)
ID_properties(f.key)
ID_PropertyFieldDefine
value
Whitesmell
  • 204
  • 2
  • 13
  • hmm...i think i quite dont understand how this fits to tables.So my tables stay the same. i add PropertyField. What is the relations?Can you explain it more please? thx – Serv0 Feb 15 '12 at 10:16
  • I never remember the name of this technique. – JeffO Feb 15 '12 at 10:16
  • Thanks, i figured it out in other way. Thanks anyway for your time. – Serv0 Feb 15 '12 at 11:24