Database Fundamentals Lecture 5. The Design Process continued.

Slides:



Advertisements
Similar presentations
More Diagramming & Practice with Relationship Modeling
Advertisements

Normalisation.
Copyright © 2015 Pearson Education, Inc. Database Design Chapters 17 and
Systems Development Life Cycle
© 2005 by Prentice Hall 1 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 7 th Edition Jeffrey A. Hoffer, Mary B.
CS263:Revision on Normalisation
Entity-Relationship Model and Diagrams (continued)
Terms - data,information, file record, table, row, column, transaction, concurrency Concepts - data integrity, data redundancy, Type of databases – single-user,
Mapping ERM to relational database
Database Design.  Define a table for each entity  Give the table the same name as the entity  Make the primary key the same as the identifier of the.
 Keys are special fields that serve two main purposes: ◦ Primary keys are unique identifiers of the relation in question. Examples include employee numbers,
Database Design Concepts
CREATE THE DIFFERENCE Normalisation (special thanks to Janet Francis for this presentation)
MIS 385/MBA 664 Systems Implementation with DBMS/ Database Management Dave Salisbury ( )
Chapter 1 Overview of Database Concepts Oracle 10g: SQL
1 Chapter 1 Overview of Database Concepts. 2 Chapter Objectives Identify the purpose of a database management system (DBMS) Distinguish a field from a.
Concepts and Terminology Introduction to Database.
MIS 301 Information Systems in Organizations Dave Salisbury ( )
Lecture 2 An Overview of Relational Database IST 318 – DB Admin.
RELATIONSHIPS Generally there are two main database types: flat-file and relational.
MIS 301 Information Systems in Organizations Dave Salisbury ( )
IT354 Database Design Seminar 5: May 19, 2011 Physical Database Design Entity-Relationship Diagrams.
University of Manitoba Asper School of Business 3500 DBMS Bob Travica
Normalization A technique that organizes data attributes (or fields) such that they are grouped to form stable, flexible and adaptive entities.
Normalisation Mia’s Sandwich Shop The Process Explained.
1 A Guide to MySQL 2 Database Design Fundamentals.
Bottom Up Analysis Bottom-up Data Analysis An Example.
SALINI SUDESH. Primarily a tool to validate and improve a logical design so that it satisfies certain constraints that avoid unnecessary duplication of.
Module Coordinator Tan Szu Tak School of Information and Communication Technology, Politeknik Brunei Semester
1 Information Retrieval and Use Data Analysis & Data Modeling, Relational Data Analysis and Logical Data Modeling Geoff Leese September 2009.
1 A Guide to MySQL 2 Database Design Fundamentals.
Chapter 1Introduction to Oracle9i: SQL1 Chapter 1 Overview of Database Concepts.
DataBase Management System What is DBMS Purpose of DBMS Data Abstraction Data Definition Language Data Manipulation Language Data Models Data Keys Relationships.
Database Fundamentals Lecture 4 Useful website for MySQL download language.com/workshops/Default.asp ?workshop=21.
Chapter 9: Logical Database Design and the Relational Model (ERD Mapping)
Unit 4 Normalisationand Relational Database Management Systems.
1 © Prentice Hall, 2002 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B.
Access Review. Access Access is a database application A database is a collection of records and files organized for a particular purpose Access supports.
Concepts of Database Management, Fifth Edition Chapter 6: Database Design 2: Design Methodology.
Database Design Normalisation. Last Session Looked at: –What databases were –Where they are used –How they are used.
CS263 Lecture 5: Logical Database Design Can express the structure of a relation by a Tuple, a shorthand notation Name of the relation is followed (in.
Lesson 2: Designing a Database and Creating Tables.
MIS 301 Information Systems in Organizations Dave Salisbury ( )
BSA206 Database Management Systems Lecture 2: Introduction to Oracle / Overview of Database Concepts.
Logical Database Design and the Relational Model.
Understand Primary, Foreign, and Composite Keys Database Administration Fundamentals LESSON 4.2.
Logical Database Design and the Relational Model.
Sample Table Standard Notation Entity name in uppercase
1 6 Concepts of Database Management, 5 th Edition, Pratt & Adamski Chapter 6 Database Design 2: Design Methodology Spring 2006.
Database Design. Database Design Process Data Model Requirements Application 1 Database Requirements Application 2 Requirements Application 4 Requirements.
Databases Database Normalisation. Learning Objectives Design simple relational databases to the third normal form (3NF).
NormalisationNormalisation Normalization is the technique of organizing data elements into records. Normalization is the technique of organizing data elements.
What Is Normalization  In relational database design, the process of organizing data to minimize redundancy  Usually involves dividing a database into.
©G. Millbery 2005Relational and Online Database Management SystemsSlide 1 Module Relational and Online Database Management Systems Normalisation.
Lecture # 17 Chapter # 10 Normalization Database Systems.
IT 5433 LM3 Relational Data Model. Learning Objectives: List the 5 properties of relations List the properties of a candidate key, primary key and foreign.
CompSci 280 S Introduction to Software Development
Order Database – ER Diagram
Intro to MIS – MGS351 Relational Database Design
Order Database – ER Diagram
SEEM3430: Information Systems Analysis and Design
Normalization Karolina muszyńska
Order Database – ER Diagram
Order Database – ER Diagram
MIS2502: Data Analytics Converting ERDs to Schemas
Order Database – ER Diagram
Database Normalisation
Order Database – ER Diagram
ER Diagram Master How to use this template
MIS2502: Data Analytics Relational Data Modeling 3
Presentation transcript:

Database Fundamentals Lecture 5

The Design Process continued

cardriver cardriver cardriver cardriver 1:1 A car can only have one driver; a driver can have only one car. 1:M A car can have more than one driver; a driver can only have one car. 1:M A car can have only one driver; a driver can have more than one car. M:N A car can have more than one driver; a driver can have more than one car.

many-to-many relationship A many-to-many relationship cannot be represented in a relational database. Take the example from last week:

Sales Staff Customer take orders Sales StaffCustomer Order acceptsplaces This many-to-many relationship does not enable mapping between a particular order and a particular member of the sales staff The entity Order uniquely defines an instance involving both Sales Staff and Customer. From a single many-to-many relationship two one-to-many relationships have been created.

Sales Staff Staffid Name DOB Employ start date Order Orderid Staffid* Customerid* Order details Customer Customerid Name Address Contact name Telephone Foreign keys

Take another example: takes student module Each student has enrolled for one or more modules AND Each module has enrolled on it zero or more students This creates the following problem:

STUDENT(studentid,student name,pathway,module1, module2, module3,module4……..) MODULE(moduleid,moduleName, student1,student2, student3,student4………..)

The solution to this problem is to create a third relation that represents the relationship itself. Such relations are called intersection relations because each row documents the intersection of a particular student with a particular module.

StudentModule Enrolment is involvedis for Each student is involved in one or more enrolments and Each enrolment involves one student and and Each enrolment is for one module and Each module is involved in zero or more enrolments Enrolment is an intersection table.

The entity and attributes are represented below: STUDENT(studentid,studentName,pathway) MODULE(moduleid,moduleName) ENROLMENT(moduleid,studentid) PRIMARY KEY - is an attribute or group of attributes that uniquely identifies each entity type, and each record in the corresponding database table. COMPOSITE KEY – is when two fields together form the unique identifier.

Entity-Relationship modelling is a top down approach to database development. It begins with study of the strategic goals of the organisation. From such a study, an abstract model is constructed. The higher level model is transformed into lower-level models. From these the application is developed. Top-Down Development

Bottom-up Development Reverse of top-down development. Begins with the need to develop a specific system. Requirements specification established from which a data model is built. The database is then designed and implemented.

Putting all data into one file or table led to logic problems when trying to manipulate the contained data. Normalisation is a technique for analysing relations based on: Primary keys Functional dependencies Series of rules Normalisation (Bottom-up development)

For example: Orders database OrderDate OrderNumber OrderQuantity1 Productid1 ProductDetail1 ProductName1 ProductPrice1 OrderQuantity2 Productid2 ProductDetail2 ProductName2 ProductPrice2 Customerid CustomerName First Normal Form (1NF) Rule: All repeating groups should be eliminated and put into separate tables Order

OrderDate OrderNo OrderQuantity1 Productid1 ProductDetail1 ProductName1 ProductPrice1 OrderQuantity2 Productid2 ProductDetail2 ProductName2 ProductPrice2 Customerid CustomerName Order FROM THISTO THIS Order OrderNo OrderDate Customerid CustomerName OrderDetail Productid ProductDetail ProductPrice OrderQuantity

Eliminating Data Repetition in a Database Order OrderNo OrderDate Customerid CustomerName To enable these tables to relate to one another it is necessary that both contain a common field. OrderDetail ItemNo Productid ProductDetail ProductPrice OrderQuantity

First Normal Form (1NF) - continued Order Now a one-to-many relationship has been established. You are no longer obliged to add a new order every time you add a new order item. One row in the OrderDetail table needs both ProductName & OrderNumber to identify it. Both fields are the primary key i.e. composite key OrderNo OrderDate Customerid CustomerName OrderDetail Productid OrderNo ProductDetail ProductPrice OrderQuantity

Order OrderDetail OrderNo OrderDate Customerid CustomerName Productid OrderNo ProductDetail ProductPrice OrderQuantity Second Normal Form(2NF) Rule: All partial dependencies must be eliminated and separated into their own tables.

Eliminating Partial Dependencies - Second Normal Form 2NF Order OrderNo OrderDate Customerid CustomerName OrderDetail OrderNo Productid OrderQuantity The OrderDetail table now contains a composite key (two fields become the primary key – OrderNo and Productid. OrderQuantity is dependent on both the fields of the composite key Product Productid ProductDetail ProductPrice

Third Normal Form (3NF) Rule: to eliminate and separate any data that is not key. All values must be uniquely identified by the key. In this example the Order table contains the Customerid and CustomerName. This data could be separated from the current table and put in to its own table. Order OrderNo OrderDate Customerid CustomerName OrderNo Productid OrderQuantity OrderDetail Product Productid ProductDetail ProductPrice

Uniquely Identifying all values - Third Normal Form (3NF) Customerid CustomerName Customer Order OrderNo OrderDate Customerid* OrderNo Productid OrderQuantity OrderDetail Product Productid ProductDetail ProductPrice Customerid links the Order table with The Customer table. Customerid is the primary key in the Customer table and Foreign key in the Order table

Places Item on Contains Entity Relationship Model (E-RM) Customer OrderDetailOrder Product

Take the Unnormalised student table below to 3NF. Studentid StudentName Pathway PathwayTutorid PathwayTutorName PathwayTutorOffice ModuleCode1 ModuleName1 FinalGrade1 ModuleCode2 ModuleName2 FinalGrade2

Possible answer Studentid StudentName Pathway PathwayTutorid PathwayTutorName PathwayTutorOffice ModuleCode ModuleName FinalGrade

1NF - Eliminating Repeating groups Studentid StudentName Pathway PathwayTutorid PathwayTutorName PathwayTutorOffice Studentid ModuleCode ModuleName FinalGrade StudentGrade

2NF- Eliminating partial dependencies. Studentid StudentName Pathway PathwayTutorid PathwayTutorName PathwayTutorOffice ModuleCode Studentid FinalGrade StudentGrade Module ModuleCode ModuleName

3NF - Uniquely Identifying all values Studentid StudentName Pathway PathwayTutorid* ModuleCode Studentid FinalGrade Student Grade PathwayTutorid PathwayTutorName PathwayTutorOffice Tutor Module ModuleCode ModuleName

Takes PathwayTutorsResults in Obtains StudentModule Grade Tutor E-RM

Practical 5 Artworks Database (Written senario included with Practical 5 details)

Artworks Database CUSTOMER (customerid, lastname, firstname, address1, address2, address3, postcode, telephone) WORK (workid, artistid, copy, description, boughtDate, boughtPrice) TRANSACTION (transactionid, workid, customerid, saleDate, salePrice) ARTIST (artistid, lastname, firstname, nationality, dob, dod) CUSTOMER-ARTIST-INT (customerid, artistid)

makes 1N creates produces interests interested in Artworks Gallery E-R Model Transaction Customer Customer-Artist-Int Artist Work