Chapter 9 Methodology Logical Database Design Chapter 16 in Textbook Objectives • Map the conceptual model into relations. • Validate these relations using the technique of normalization. • Validate a logical data model to ensure it supports required user transactions. • Merge local logical data models based on specific views into a global logical data model of the enterprise. • Ensure that resultant global model is a true and accurate representation of enterprise. Logical DB Design 2 Step 2 Build and Validate Local Logical Data Model Step 2.1 Derive relations for local logical data model Step 2.2 Validate relations using normalization Step 2.3 Validate relations against user transactions Step 2.4 Define integrity constraints Step 2.5 Review local logical data model with user Logical DB Design 3 Step 2.1 Derive relations for local logical data model Objective: To create relations for the local logical data model to represent the entities, relationships, and attributes that have been identified. – Strong entity types. – Weak entity types. – 1:1 binary relationship types. – 1:M relationship types. – 1:1 recursive relationship types. – Superclass/Subclass relationship types. – M:N relationship types. Document relations and foreign key attributes. Logical DB Design 4 Relations for the Staff View of DreamHome Staff (staffNo, FName, Lname, position, sex, DOB, SupervisorStaffNo) Foreign Key SupervisorStaffNo reference Staff(StaffNo) BusinessOwner (OwnerNo, BName, Btype, ContactName, address, TelNo) Alternate Key bName Alternate Key TelNo Lease (LeaseNo, PaymentMethod, depositPaid, RentStart, RentFinish, ClientNo, PropertyNo) Alternate Key PropertyNo, RentStart Foreign Key ClientNo refrences Client(ClientNo) Foreign Key PropertyNo refrences Client(ClientNo) Derived deposit (PropertForRent.rent * 2) Derived duration (RentFinish -RentStart) Logical DB Design 5 Step 2 Build and Validate Local Logical Data Model Step 2.2 Validate relations using normalization Objective: To ensure that each relation is in at least BCNF. Step 2.3 Validate relations against user transactions Objective: To ensure that the relations in the local logical data model support the transactions required by the view. Logical DB Design 6 Step 2 Build and Validate Local Logical Data Model Step 2.4 Define integrity constraints Integrity constraints protects DB from being inconsistent. Types of integrity constraints: – Required data. – Entity integrity. – Referential integrity. – Attribute domain. – Enterprise constraints. Logical DB Design 7 Step 2 Build and Validate Local Logical Data Model In testing referential integrity check the following cases: • Insert tuple into child relation. • Delete tuple from child relation. • Update FK of child tuple. • Insert tuple into parent relation. • Delete tuple from parent relation. • Update PK of parent tuple. Logical DB Design 8 Referential Integrity Constraints for Relations Staff (staffNo, FName, Lname, position, sex, DOB, SupervisorStaffNo) Foreign Key SupervisorStaffNo reference Staff(StaffNo) ON UPDATE CASCADE ON DELETE SET NULL BusinessOwner (OwnerNo, BName, Btype, ContactName, address, TelNo) Alternate Key bName Alternate Key TelNo Lease (LeaseNo, PaymentMethod, depositPaid, RentStart, RentFinish, ClientNo, PropertyNo) Alternate Key PropertyNo, RentStart Foreign Key ClientNo refrences Client(ClientNo) ON UPDATE CASCADE ON DELETE NO ACTION Foreign Key PropertyNo refrences Client(ClientNo) ON UPDATE CASCADE ON DELETE NO ACTION Derived deposit (PropertForRent.rent * 2) Derived duration (RentFinish -RentStart) Logical DB Design 9 Step 2 Build and Validate Local Logical Data Model Step 2.5 Review local logical data model with user Objective: To ensure that the local logical data model and supporting documentation that describes the model is a true representation of the view. Logical DB Design 10 Step 3 Build and validate global logical data model Combine the individual local logical data models into a single global logical data model that represents the enterprise. Step 3.1 Merge local logical data models into global model Step 3.2 Validate global logical data model Step 3.3 Check for future growth Step 3.4 Review global logical data model with users Logical DB Design 11 Step 3.1 Merge local logical data models into global model 1. Review the names & contents of entities/relations and their CK. 2. Review the names & contents of relationships/FK. 3. Merge entities/relations from the local models. 4. Include (without merging) entities/relations unique to each local model. 5. Merge relationships/FK from the local models. 6. Include (without merging) relationships/FKs unique to each local model. 7. Check the missing entities/relations and relationships/FKs. 8. Check FKs. 9. Check integrity constraints. 10. Draw the global ER/relation diagram. 11. Update the documentation. 12 1. Review the names & contents of entities/relations and their CK Branch View Entity Type CK Branch Telephone Staff Manager PrivateOwner BusinessOwner Client PropertyForRent Lease Logical DB Design BranchNo PostCode TelNo StaffNo StaffNo OwnerNo Bname telNo ClientNo Propertyno LeaseNo PropertyNo RentStart ClientNo, RentStart Staff View Entity Type CK Staff StaffNo PrivateOwner BusinessOwner OwnerNo Bname telNo OwnerNo ClientNo Propertyno ClientNo, PropertyNo Client PropertyForRent Viewing 13 2. Review the names & contents of relationships/FK Staff View Branch View Relation FK Relationship Branch mgrStaffNo -> Manager(StaffNo) Telephone branchN -> Branch(branchNo) Staff supervisorStaffNo -> Staff(staffNo) Manager branchNo -> Branch(branchNo) PrivateOwner StaffNo -> Staff(StaffNo) FK Relationship Manages Supervisor supervisorStaffNo -> Staff(staffNo) Supervisor BusinessOwner Client PropertyForRent Registers OwnerNo -> PrivateOwner(ownerNo) Owns OwnerNo -> PrivateOwner(ownerNo) POwns OwnerNo -> Owns OwnerNo -> BOwns BusinessOwner(ownerNo) Viewing StaffNo -> Staff(StaffNo) BusinessOwner(ownerNo) StaffNo -> Staff(StaffNo) Oversees BranchNo -> Branch(BranchNo) Offers Logical DB Design StaffNo -> Staff(StaffNo) Manages 14 3. Merge entities/relations from the local models 1. Merge entities/relations with the same name & the same PK. Branch View Staff View PRIVATE OWNER(Ono, name, address) PRIVATE OWNER(Ono, fname, lname, address) Global View PRIVATE OWNER(Ono, fname, lname, address) Logical DB Design 15 3. Merge entities/relations from the local models 2. Merge entities/relations with the same name but different PK. Branch View Staff View BOWNER(bName, bType, address) BOWNER(Ono, bName, bType, address) AK telNo AK bName, telNo Global View BOWNER(Ono, bName, bType, address) AK bName, telNo 3. Merge entities/relations with the different names using the same or different PK. Logical DB Design 16 4. Include (without merging) entities/relations unique to each local model The Previous task should identify all entities/relations that are the same. All remaining entities/relations are included in the global model without change. Logical DB Design 17 5. Merge relationship/FK from the local models 1. Merge relationship/FKs with the same name & the same purpose. 2. Merge relationship/FKs with different names but the same purpose. Logical DB Design 18 6. Include (without merging) relationships/FKs unique to each local model Again, the Previous task should identify all relationships/FKs that are the same. All remaining relationships/FKs are included in the global model without change. Logical DB Design 19 Step 3 Build and Validate Global Logical Data Model Step 3.2 Validate global logical data model Objective: To validate the relations created from the global logical data model using the technique of normalization and to ensure they support the required transactions, if necessary. Step 3.3 Check for future growth Objective: To determine whether there are any significant changes likely in the foreseeable future and to assess whether the global logical data model can accommodate these changes. Step 3.4 Review global logical data model with users Objective: To ensure that the global logical data model is a true representation of the enterprise. Logical DB Design 20