140 likes | 259 Views
Advanced Data Modeling. Why Needs A Database. To maintain consistency and integrity in your data by reducing redundancy and eliminating anomalies via Data Modeling and Database Design. Normalization. All attributes must be single-valued . First Normalization .
E N D
Why Needs A Database • To maintain consistency and integrity in your data by reducing redundancy and eliminating anomalies via Data Modeling and Database Design.
Normalization • All attributes must be single-valued. • First Normalization. • All attributes must be dependent on its entity’s entire UID. • Second Normalization. • No non-UID attribute can be dependent on another non_UID attribute. • Third Normalization.
LEAVE EMPLOYEE EMPLOYEE #* id * name #* type #* start_date #*end_date • #* id • Name • 。leave_type • * leave_date 1st Normalization • All attributes must be single-valued. (1) To resolve, add an entity LEAVE #* employee_id
1st Normalization Ex. 差假系統: 記錄員工請假資料 EMPLOYEE id name phone address leave_type leave_date Has multi-values Repeat Group
PROD_ITEM ORDER ORDER #* id * status *date #* id * name *description #* id * status 。date * prod_item 1st Normalization(續) (2) To resolve, add an entity PROD_ITEM #* order_id
1st Normalization(續) • The above process is called 1st normalization. The final result is said to be in 1NF(Normalization Form). • Conclusion: • If an attribute has multi-valued attribute, create an additional entity and relate it to the original entity with M:1 relationship.
COURSE ACCOUNT PRODUCT #* id * name 。fee * duration #* number * balance 。date_opened * bank_location #* name #* warehouse 。Warehouse_ location 2nd Normalization • All attributes must be dependent on its entity’s entire UID. OK Not dependent on its UID
2nd Normalization(續) • The above process is called 2nd normalization. The final result is said to be in 2NF(Normalization Form). • Conclusion: • If an attribute is not dependent on its entire UID, it is misplaced and must be moved.
TUTOR #* id * name *department * dept_location *dept_phone 3rd Normalization • No non-UID attribute can be dependent on another non_UID attribute. (1) dept_location(系辦位置) and dept_phone(系辦電話)are dependent upon Department(系)
TUTOR DEPARTMENT #* id * name #* name * location * phone 3rd Normalization(續) Way to resolve:
EMPLOYEE #* id * name *work_depart * mgrno *admrdept *location 3rd Normalization(續) (2) mgrno(主管代號) , Admrdept(主管部門)and Location( 部門地點) are dependent upon work_depart(工作部門)
EMPLOYEE DEPARTMENT #* id * name #* id * name * mgrno * admrdept * location 3rd Normalization(續) Way to resolve:
3rd Normalization(續) • The above process is called 3rd normalization. The final result is said to be in 3NF(Normalization Form). • Conclusion: • If an attribute is dependent upon a non_UID attribute, move both the dependent attribute and the attribute it is dependent upon to a new related entity.