database - Inheritance and model Id -


i have person class in contacts subsystem. on other hand in crm subsystem, have notion of customer.

in database design, want create relationship between these notions. there possible ways:

  1. each customer is person, customer should inherit person , customer dies person removed (composition). in case, create one-to-one relationship between id columns of customers table , people table, , make id column of people table identity field, explicitly insert scope_identity() in customers table.
  2. each customer has person, customer , person have own life-cycles (aggregation) , can survive without other. in scenario, customers table should have foreign key people table. bad point here each person can have many customers seems odd me.

which design suggested best practice? need solid objective answers. thank you.

there different cases when may or may not give each table it's own id.

in case, better if customer table have it's own id.

example: own id in many many relation defining table redundant, when doesn't have column associated apart tables joining. consider teacher , student table relation. have many many relation. if there table named teacherstudentrelation having foreign key teacher , student table won't need ownid field.

but in case, customer table surely have information associated balance, purchaselist or that. , highly search customer table data. here ownid of customer table let index table.

briefly, give customer table it's own id.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -