sql server - How to implement this data structure in SQL tables -
i have problem can summarized follow:
assume implementing employee database. each person depends on position, different fields should filled. example if employee software engineer, have following columns:
name family language technology candevelopweb and if employee business manager have following columns:
name family fieldofexpertise maximumcontractvalue bonusrate and if employee salesperson other columns , on.
how can implement in database schema?
one way thought have related tables:
coretable:
name family type and if type 1 employee software developer , hence remaining information should in table softwaredeveloper:
language technology candevelopweb for business managers have table columns:
fieldofexpertise maximumcontractvalue bonusrate the problem structure not sure how make relationship between tables, 1 table has relationship several tables on 1 column.
how enforce relational integrity?
there few schools of thought here.
(1) store nullable columns in single table , populate relevant ones (check constraints can enforce integrity here). people don't because afraid of nulls.
(2) multi-table design each type gets own table. tougher enforce dri trivial application or trigger logic.
the problem either of those, add new property (like canreadupsidedown), have make schema changes accommodate - in (1) need add new column , new constraint, in (2) need add new table if represents new "type" of employee.
(3) eav, have single table stores property name , value pairs. have less control on data integrity here, can constraint property names strings. wrote here: http://sqlblog.com/blogs/aaron_bertrand/archive/2009/11/19/what-is-so-bad-about-eav-anyway.aspx
Comments
Post a Comment