Www.hope.ac.uk Deanery of Business & Computer Sciences Transformation of Logical Diagram into Database Design Language Lecture 6 Database Technology Level.

Slides:



Advertisements
Similar presentations
Database Design: Normalization J.G. Zheng June 29 th 2005 DB Chapter 4.
Advertisements

Normalisation.
Normalisation 1 Chapter 4.1 V3.0 Napier University Dr Gordon Russell.
Normalisation Ensuring data integrity in database design 1.
Monash University Week 7 Data Modelling Relational Database Theory IMS1907 Database Systems.
Systems Development Life Cycle
Conceptual Design Lecture 3 Database Development.
Normalisation “A formal technique for analysing relations based on their primary key and functional dependencies.” [Codd]. Process – Analyse each relation.
Database Design Conceptual –identify important entities and relationships –determine attribute domains and candidate keys –draw the E-R diagram Logical.
RELATIONSHIP  THE WAY TABLES ARE RELATED  A TABLE MUST PARTICIPATE IN AT LEAST ONE RELATIONSHIP  IN A BINARY RELATIONSHIP TWO ENTITIES PARTICIPATE 
1 © Prentice Hall, 2002 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B.
1 NORMALISATION. 2 Introduction Overview Objectives Intro. to Subject Why we normalise 1, 2 & 3 NF Normalisation Process Example Summary.
INFO 340 Lecture 7 Functional Dependency, Normalization.
Chapter 5 Normalization of Database Tables
Project and Data Management Software
Chapter 4 Relational Databases Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 4-1.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education 4-1.
LOGICAL DATABASE DESIGN
Michael F. Price College of Business Chapter 6: Logical database design and the relational model.
Normalization. Introduction Badly structured tables, that contains redundant data, may suffer from Update anomalies : Insertions Deletions Modification.
Week 6 Lecture Normalization
Lecture 12 Inst: Haya Sammaneh
Modelling Techniques - Normalisation Description and exemplification of normalisation.Description and exemplification of normalisation. Creation of un-normalised.
CREATE THE DIFFERENCE Normalisation (special thanks to Janet Francis for this presentation)
DAY 15: ACCESS CHAPTER 2 Larry Reaves October 7,
Section 11 : Normalisation
MIS 385/MBA 664 Systems Implementation with DBMS/ Database Management Dave Salisbury ( )
Concepts and Terminology Introduction to Database.
Relational databases and third normal form As always click on speaker notes under view when executing to get more information!
Relational Database Management Systems. A set of programs to manage one or more databases Provides means for: Accessing the data Inserting, updating and.
Component 4: Introduction to Information and Computer Science Unit 6: Databases and SQL Lecture 4 This material was developed by Oregon Health & Science.
Normalization A technique that organizes data attributes (or fields) such that they are grouped to form stable, flexible and adaptive entities.
RDBMS Concepts/ Session 3 / 1 of 22 Objectives  In this lesson, you will learn to:  Describe data redundancy  Describe the first, second, and third.
Normalization (Codd, 1972) Practical Information For Real World Database Design.
Concepts of Relational Databases. Fundamental Concepts Relational data model – A data model representing data in the form of tables Relations – A 2-dimensional.
Database Design (Normalizations) DCO11310 Database Systems and Design By Rose Chang.
Normalisation Rules and Practical Application Geoff Leese January 2010.
Logical Database Design Relational Model. Logical Database Design Logical database design: process of transforming conceptual data model into a logical.
In this chapter, you learn about the following: ❑ Anomalies ❑ Dependency and determinants ❑ Normalization ❑ A layman’s method of understanding normalization.
CORE 2: Information systems and Databases NORMALISING DATABASES.
MS Access: Creating Relational Databases Instructor: Vicki Weidler Assistant: Joaquin Obieta.
Deanery of Business & Computer Sciences SQL Structured Query Language Implementation Lecture – 8 Database Technology Level I.
Normalization Well structured relations and anomalies Normalization First normal form (1NF) Functional dependence Partial functional dependency Second.
1 5 Normalization. 2 5 Database Design Give some body of data to be represented in a database, how do we decide on a suitable logical structure for that.
Chapter 9 Logical Database Design : Mapping ER Model To Tables.
SQL Structured Query Language. Aims  To introduce the implementation of a Physical design using SQL.  To introduce SQL Data Definition Language (DDL).
What is normalization ? Proposed by Codd in 1972 Takes a relation through a series of steps to certify whether it satisfies a certain normal form Initially.
Lection №4 Development of the Relational Databases.
Conceptual Design to Logical Design Lecture 4. Aims  To introduce Business Rules  To identify what a Business Rule is  To Introduce Business Operations.
Logical Database Design and the Relational Model.
Databases Database Normalisation. Learning Objectives Design simple relational databases to the third normal form (3NF).
Lecture 4: Logical Database Design and the Relational Model 1.
Normalization. Overview Earliest  formalized database design technique and at one time was the starting point for logical database design. Today  is.
NormalisationNormalisation Normalization is the technique of organizing data elements into records. Normalization is the technique of organizing data elements.
IMS 4212: Normalization 1 Dr. Lawrence West, Management Dept., University of Central Florida Normalization—Topics Functional Dependency.
Databases Introduction - concepts. Concepts of Relational Databases.
Logical Database Design and Relational Data Model Muhammad Nasir
What Is Normalization  In relational database design, the process of organizing data to minimize redundancy  Usually involves dividing a database into.
MS Access. Most A2 projects use MS Access Has sufficient depth to support a significant project. Relational Databases. Fairly easy to develop a good user.
Normalisation Unit 6: Databases. Just to recap  What is an Entity  What is an Attribute?
Lecture # 14 Chapter # 5 The Relational Data Model and Relational Database Constraints Database Systems.
Dr Gordon Russell, Napier University Normalisation 1 - V2.0 1 Normalisation 1 Unit 3.1.
April 20022/CS/3X1 Database Design Design method John Wordsworth Department of Computer Science The University of Reading Room.
Database, tables and normal forms
A brief summary of database normalization
Conceptual and Physical Database Design
Chapter 5: Logical Database Design and the Relational Model
Chapter 4 Relational Databases
Chapter 4.1 V3.0 Napier University Dr Gordon Russell
Normalisation 1 Unit 3.1 Dr Gordon Russell, Napier University
Presentation transcript:

Deanery of Business & Computer Sciences Transformation of Logical Diagram into Database Design Language Lecture 6 Database Technology Level I

Deanery of Business & Computer Sciences 2 Aims To introduce the production of Database Design Language (DDL) from a Logical diagram. To introduce referential integrity rules. An overview of Normalisation – First Normal Form (1NF) – Second Normal Form (2NF) – Third Normal Form (3NF)

Deanery of Business & Computer Sciences 3 Database Design Language (DDL) Given an entity, “EntityName” with n attributes, the DDL structure is as follows – EntityName (PrimaryKey(s), attribute 1, attribute 2,…, attribute n ) We can also define foreign keys (FK) as follows with restrictions on operations we can/cant do : – FK ForeignKeyAttributeName →ParentEntityName Update→Cascade or Restrict Delete→Cascade or Restrict

Deanery of Business & Computer Sciences 4 Delete Rules – Applies to parent entity with related child entity instances tblPractice PIDPractice name P122Cherry Tree P144South Street P134Concourse tblPatient NHSNoPSnamePrID NH223ParkinsonP122 NH564ParkinsonP122 NH453DickensonP122 NH455JonesP134 Cascade: Always permits deletion of parent entity instance and deletes all matching instances in the child entity

Deanery of Business & Computer Sciences 5 Delete Cascade tblPractice PIDPractice name P122Cherry Tree P144South Street P134Concourse tblPatient NHSNoPSnamePrID NH223ParkinsonP122 NH564ParkinsonP122 NH453DickensonP122 NH455JonesP134 Delete To Cascade is to “track stages in succession ” Delete rule cascades down to child instances in This case

Deanery of Business & Computer Sciences 6 Delete Rules tblPractice PIDPractice name P134Concourse P144South Street tblPatient NHSNoPSnamePrID NH455JonesP134

Deanery of Business & Computer Sciences 7 Delete Restrict tblPractice PIDPractice name P122Cherry Tree P144South Street P134Concourse tblPatient NHSNoPSnamePrID NH223ParkinsonP122 NH564ParkinsonP122 NH453DickensonP122 NH455JonesP134 Delete You may not delete the practice entity instance only, as there are related records in table tblPatient Restrict: Permits deletion of parent entity instance only if there are no matching child entity instances

Deanery of Business & Computer Sciences 8 Delete Rules tblPractice PIDPractice name P122Cherry Tree P144South Street P134Concourse tblPatient NHSNoPSnamePrID NH223ParkinsonP122 NH564ParkinsonP122 NH453DickensonP122 NH455JonesP134 Delete Restrict: Permits deletion of parent entity “P144, South Street” instance since there are no matching child entity instances with P144

Deanery of Business & Computer Sciences 9 Delete Rules tblPractice PIDPractice name P122Cherry Tree P134Concourse tblPatient NHSNoPSnamePrID NH223ParkinsonP122 NH564ParkinsonP122 NH453DickensonP122 NH455JonesP134

Deanery of Business & Computer Sciences 10 Update Cascade- Applies to parent entity primary key with related child entity instances tblPractice PIDPractice name P122Cherry Tree P144South Street P134Concourse tblPatient NHSNoPSnamePrID NH223ParkinsonP122 NH564ParkinsonP122 NH453DickensonP122 NH455JonesP134 P333 Note: The foreign key in the child is created by migrating the primary Key from the parent entity. Restrict: only allowed if a parent record to be updated doesn’t get child orphans Cascade: Parent to child entities if they exist

Deanery of Business & Computer Sciences 11 Update Restrict tblPractice PIDPractice name P122Cherry Tree P144South Street P134Concourse tblPatient NHSNoPSnamePrID NH223ParkinsonP122 NH564ParkinsonP122 NH453DickensonP122 NH455JonesP134 P333 You may not update only the primary key of a practice entity instance if there are related records in table tblPatient

Deanery of Business & Computer Sciences 12 Logical to Database Design Language DDL (Schema) for Tutor Tutor (tutorID, firstName, surname, address1,address2, postcode, contractType, hourlyRate) firstName surname address1 address2 postcode contractType hourlyRate tutorID Tutor semester classRoom classDay classTime courseCode(fk) tutorID(fk) className Class Note that Sometimes the DDL is called a “schema” ALWAYS UNDERLINE the primary key(s) or Foreign keys

Deanery of Business & Computer Sciences 13 Logical to DDL DDL for Class Class (className, semester, classRoom, classDay,classTime, courseCode, tutorID) FK tutorID→Tutor update cascade delete restrict firstName surname address1 address2 postcode contractType hourlyRate tutorID Tutor semester classRoom classDay classTime courseCode tutorID(FK) className Class

Deanery of Business & Computer Sciences 14 Cumulative Design Student(studentID, sFirstName, sSurname, sAdd1, sAdd2, sAdd3, sPostcode, sTelephone, lastApplicationDate) Course (courseCode, title, cost) Tutor (tutorID, firstName, surname, address1, address2, postcode, contractType, hourlyRate) Class (className, semester, classroom, classDay, classTime, courseCode, tutorID) FK tutorID→Tutor Update Cascade, Delete Restrict FK courseCode→course Update Cascade, Delete Restrict StudentCourse (studentID, courseCode) FK studentID→Student Update Cascade, Delete Restrict FK courseCode→course Update Cascade, Delete Restrict StudentClass (StudentID, className) FK studentID→Student Update Cascade, Delete Restrict FK className→ Class Update Cascade, Delete Restrict

Deanery of Business & Computer Sciences 15 Normalisation What is normalisation? Normalisation is – a set of criteria – Each criteria is a rule for designing entities

Deanery of Business & Computer Sciences 16 Normalisation Why normalisation? Normalisation helps us to – improve the quality of entities – produce entities that have as little redundancy as possible – accommodate multiple values for types of data that require them – permit efficient updates of the data in the database – avoid the danger of losing data unknowingly

Deanery of Business & Computer Sciences 17 Normalisation How we use it in this course! We will use the normalisation rules up to third normal form.

Deanery of Business & Computer Sciences 18 First Normal Form (1NF) Definition of INF: Take an unnormalised relation and remove any repeating group to form a new entity, combining the original primary key with the primary key in the repeating group to form a new compound primary key.

Deanery of Business & Computer Sciences 19 First Normal form (1NF) You will need to check that each attribute will only need to hold one value, if more than one value is needed the entity is not in first normal form.

Deanery of Business & Computer Sciences 20 Example We record for the Medical Staff all the procedures they are qualified to carry out MedicalStaff MedStaffID MSFName MSSName MSAdd MSType MSProcedureID MSProcedure DeptID DeptName Database Design Language MedStaff (MedStaffID, MSFName, MSSName, MSAdd, MSType, MSProcedureID, MSProcedure, DeptID, DeptName)

Deanery of Business & Computer Sciences 21 Example Database Design Language ONF MedicalStaff (MedStaffID, MSFName, MSSName,MSAdd, MSType, DeptID, DeptName, (MSProcedureID, MSProcedure)) The entity is split into two separate entities. Both of which are in first normal form. Foreign Keys will be dealt with later. INF MedicalStaff (MedStaffID, MSFName, MSSName, MSAdd, MSType, DeptID, Deptname) StaffProcedure (MedStaffID, MSProcedureID, MSProcedure)

Deanery of Business & Computer Sciences 22 Second Normal Form (2NF) Definition of 2NF: "ensure that all non-key attributes are fully dependent on the whole of the primary key" i.e. remove all partial dependencies through the creation of new tables where there was a compound key.

Deanery of Business & Computer Sciences 23 Second Normal Form (2NF) Any entity with a single primary key is automatically second normal form. We apply the rule to any entity with a compound key.

Deanery of Business & Computer Sciences 24 Second Normal Form (2NF) Entities in first Normal Form MedicalStaff (MedStaffID, MSFName, MSSName, MSAdd, MSType, DeptID, DeptName) MedicalStaff is automatically 2NF as it has a single primary key. StaffProcedure (MedStaffID, ProcedureID, MSProcedure) StaffProcedure may not be in 2NF as it has a compound key and needs to be checked.

Deanery of Business & Computer Sciences 25 Second Normal Form Entities in first Normal Form MedicalStaff (MedStaffID, MSFName, MSSName, MSAdd, MSType, DeptID, DeptName) StaffProcedure (MedStaffID, ProcedureID, MSProcedure) The StaffProcedure entity is split into two separate entities. Both of which are in second normal form. 2NF MedicalStaff (MedStaffID, MSFName, MSSName, MSAdd, MSType, DeptID, DeptName) StaffProcedure (MedStaffID, ProcedureID) Procedure (ProcedureID, MSProcedure)

Deanery of Business & Computer Sciences 26 Third Normal Form Definition of 3NF: "ensure that all non-key attributes are mutually independent apart from candidate attributes" i.e. remove the dependencies between the non-key attributes through the creation of new tables.

Deanery of Business & Computer Sciences 27 Third Normal Form (3NF) An entity with no non key attributes is automatically in third normal form. An entity with only one non key attribute is automatically in third normal form.

Deanery of Business & Computer Sciences 28 Third Normal Form Entities in second Normal Form MedicalStaff (MedStaffID, MSFName, MSSName, MSAdd, MSType, DeptID, DeptName) StaffProcedure (MedStaffID, ProcedureID) Procedure (ProcedureID, MSProcedure) Medical Staff has more than one non key field so we must consider it against the rule for 3NF. StaffProcedure has no non key fields so is in 3NF. Procedure has one non key field so is in 3NF.

Deanery of Business & Computer Sciences 29 Third Normal Form Entities in second Normal Form MedicalStaff (MedStaffID, MSFName, MSSName, MSAdd, MSType, DeptID, DeptName) StaffProcedure (MedStaffID, ProcedureID) Procedure (ProcedureID, MSProcedure) In MedicalStaff there is a dependency between DeptID and DeptName therefore MedicalStaff is not in 3NF. DeptID DeptName

Deanery of Business & Computer Sciences 30 Third Normal Form Entities in third Normal Form MedicalStaff (MedStaffID, MSFName, MSSName, MSAdd, MSType, DeptID) Department (DeptID, DeptName) StaffProcedure (MedStaffID, ProcedureID) Procedure (ProcedureID, MSProcedure) We must now deal with the foreign keys in the relations.

Deanery of Business & Computer Sciences 31 Entities in Third Normal Form Department (DeptID, DeptName) MedicalStaff (MedStaffID, MSFName, MSSName, MSAdd, MSType, DeptID) FK DeptID → Department Update Cascade, Delete Restrict Procedure (ProcedureID, MSProcedure) StaffProcedure (MedStaffID, ProcedureID) FK MedStaffID → MedicalStaff Update Cascade, Delete Restrict FK ProcedureID → Procedure Update Cascade, Delete Restrict

Deanery of Business & Computer Sciences 32 Summary Introduction to Database design language. Use of update and delete rules Normalisation – First normal form – Second normal form – Third normal form Specification of Foreign keys in DDL

Deanery of Business & Computer Sciences 33 NEXT WEEK Noun identification table Conceptual E-R Diagram Conceptual Diagram script Business Rules Operations Logical model Database Design Language Normalisation.