Transforming the Data Model into Relations (Tables) and Normalisation

Similar documents
Normalization. Normal Forms. Normal Forms

Detailed Data Modelling. Detailed Data Modelling. Detailed Data Modelling. Identifying Attributes. Attributes

Detailed Data Modelling: Attribute Collection and Normalisation of Data

Normalization Rule. First Normal Form (1NF) Normalization rule are divided into following normal form. 1. First Normal Form. 2. Second Normal Form

Schema Normalization. 30 th August Submitted By: Saurabh Singla Rahul Bhatnagar

Introduction to Database. Dr Simon Jones Thanks to Mariam Mohaideen

Database Systems CSE Comprehensive Exam Spring 2005

Entity-Relationship Model

Practice Problem for the Bonus Part of Take Home Assignment 2

Normalisation Chapter2 Contents

IS 263 Database Concepts

Ch 9: Mapping EER to Relational. Follow a seven-step algorithm to convert the basic ER model constructs into relations steps 1-7

1) Introduction to SQL

MIS Database Systems Entity-Relationship Model.

How To Convert An Er Diagram Into Relational Schema Example

Logical Database Design. ICT285 Databases: Topic 06

The DBMS accepts requests for data from the application program and instructs the operating system to transfer the appropriate data.

BCS THE CHARTERED INSTITUTE FOR IT BCS HIGHER EDUCATION QUALIFICATIONS BCS Level 5 Diploma in IT DATABASE SYSTEMS

1. Heading 1. Normalisation LEARNING OBJECTIVES. Study Guide. On completion of this session you will be able to:

SIT772 Database and Information Retrieval

پوهنتون کابل پوهنحی كمپيوترساینس پوهنیار محمد شعیب "زرین خیل"

Databases. Dr. Richard E. Turner March 5, 2013

Database Normalization. (Olav Dæhli 2018)

Functional Dependency

Database Design. A Bottom-Up Approach

CS2 Databases TEST 1 25 August 2003 Student Number: MARK: /35

The Relational Model and Normalization

Mapping ER Diagrams to. Relations (Cont d) Mapping ER Diagrams to. Exercise. Relations. Mapping ER Diagrams to Relations (Cont d) Exercise

CS403- Database Management Systems Solved MCQS From Midterm Papers. CS403- Database Management Systems MIDTERM EXAMINATION - Spring 2010

CMSC 424 Database design Lecture 3: Entity-Relationship Model. Book: Chap. 1 and 6. Mihai Pop

A Flat file database. Problems with a flat file database (data redundancy)

Chapter 7: Entity-Relationship Model

BSc (Hons) Software Engineering. BSc (Hons) Computer Science with Network Security. Examinations for / Semester 2 & 2017 / Semester 1

Chapter 7: Entity-Relationship Model

Chapter 7 Advanced SQL. Objectives

Roadmap of This Lecture. Weak Entity Sets Extended E-R Features Reduction to Relation Schemas Database Design UML*

Normalisation. Connolly, Ch. 13

L11: ER modeling 4. CS3200 Database design (sp18 s2) 2/15/2018

Learning outcomes. On successful completion of this unit you will: 1. Understand data models and database technologies.

Chapter 2 Introduction to Relational Models

Data Analysis 1. Chapter 2.1 V3.1. Napier University Dr Gordon Russell

Chapter 7: Entity-Relationship Model

Relational Database Design (II)

Chapter 7: Entity-Relationship Model

Entity Relationship Modelling

Official Statistics - Relational Database Management Systems. Official Statistics - Relational Database Management Systems

Redundancy:Dependencies between attributes within a relation cause redundancy.

CS403- Database Management Systems Solved Objective Midterm Papers For Preparation of Midterm Exam

Chapter 6. Foundations of Business Intelligence: Databases and Information Management VIDEO CASES

Pirate Sports Database Tables/Fields

Chapter 8: Relational Database Design

Schema And Draw The Dependency Diagram

UNIVERSITY OF BOLTON WESTERN INTERNATIONAL COLLEGE FZE BSC (HONS) COMPUTING SEMESTER ONE EXAMINATION 2015/2016 DATABASE THEORY AND PRACTICE

MIDTERM EXAMINATION Spring 2010 CS403- Database Management Systems (Session - 4) Ref No: Time: 60 min Marks: 38

Chapter 2 ENTITY RELATIONSHIP MODEL

GUJARAT TECHNOLOGICAL UNIVERSITY

EE221 Databases Practicals Manual

1. Considering functional dependency, one in which removal from some attributes must affect dependency is called

SWEN-220 Mathematical Models of Software. Conceptual to Relational Mapping

Objectives Definition iti of terms List five properties of relations State two properties of candidate keys Define first, second, and third normal for

CONCEPTUAL DESIGN: ER TO RELATIONAL TO SQL

Physical DB Issues, Indexes, Query Optimisation. Database Systems Lecture 13 Natasha Alechina

Unit 3 : Relational Database Design

Chapter 6: Relational Database Design

Databases and PHP. Storing and Retrieving information

3/3/2008. Announcements. A Table with a View (continued) Fields (Attributes) and Primary Keys. Video. Keys Primary & Foreign Primary/Foreign Key

CS211 Lecture: Database Design

CS425 Fall 2016 Boris Glavic Chapter 2: Intro to Relational Model

CS252:HACD Fundamentals of Relational Databases Notes for Section 9: Database Design Issues, Part II

L12: ER modeling 5. CS3200 Database design (sp18 s2) 2/22/2018

Exam code: Exam name: Database Fundamentals. Version 16.0

RELATIONAL DATABASE DESIGN. Basic Concepts

Lecturer 2: Spatial Concepts and Data Models

Networks and Web for Health Informatics (HINF 6220)

Exemplar Candidate Work Part 1 of 2 GCE in Applied ICT. OCR Advanced GCE in Applied ICT: H715 Unit G057: Database design

Normalization. Murali Mani. What and Why Normalization? To remove potential redundancy in design

Object Modeling. Entity-Relationship (ER) diagrams (1976) Object Modelling Technique (OMT) diagrams (1991)

Unit I. By Prof.Sushila Aghav MIT

Chapter 2: Intro to Relational Model

Part 7. Logical Data Structures

Database Management System Prof. Partha Pratim Das Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur

Implementing and Maintaining Microsoft SQL Server 2008 Integration Services

A hypothetical M:M student schedule example

CSIT5300: Advanced Database Systems

Data Analysis 2. Chapter 2.2 V3.0. Napier University Dr Gordon Russell

Database Tables and Normalization

Informal Design Guidelines for Relational Databases

Entity Relationship Diagram (ERD) Dr. Moustafa Elazhary

Chapter 7: Entity-Relationship Model. Chapter 7: Entity-Relationship Model

Module Definition Form (MDF)

Review The Big Picture

LAB 2 Notes. Conceptual Design ER. Logical DB Design (relational) Schema Refinement. Physical DD

Lecture 3. Wednesday, September 3, 2014

The University of Nottingham

Announcements (January 20) Relational Database Design. Database (schema) design. Entity-relationship (E/R) model. ODL (Object Definition Language)

Database Foundations. 3-9 Validating Data Using Normalization. Copyright 2015, Oracle and/or its affiliates. All rights reserved.

CSCE 4523 Introduction to Database Management Systems Final Exam Spring I have neither given, nor received,unauthorized assistance on this exam.

Dependency Diagram To Meet The 3nf

THE COPPERBELT UNIVERSITY

Entity-Relationship Modelling. Entities Attributes Relationships Mapping Cardinality Keys Reduction of an E-R Diagram to Tables

Transcription:

Transforming the Data Model into Relations (Tables) and Normalisation Students 1 External Level Specification - Identify all User views User View - subset of data required by user. Takes the form of printed report-e.g. register screen display - e.g.. all student info.. input form routine query - e.g. how many students on course? ad hoc query - e.g. which courses does F.Bloggs take 2 Draw an ER diagram of each user view integrate to produce ER diagram of system (each entity with attributes to appear only once) This should ensure that all the attributes have been included 3

Transforming the data model into Tables (relations) each entity becomes a table with a column for each attribute, the entity identifier is the for the table. 1:N relationship is represented by placing the on one side of the relationship, as a foreign key in the table for the entity in the many side 4 e.g. customer : order (a one to many relationship) CUSTOMER TABLE cust-no. name address city ORDER TABLE discount one order-no. order-date promised-date cust-no. Many foreign key 5 An M:N (Many to Many) relationship To avoid an invalid construct, create a new table to represent the relationship, the for this is a composite key comprising of the s of the entities on either side of the relationship. e.g. ORDER REQUESTED ON PRODUCT QUANTITY ORDERED 6

M:N relationship example (contd) ORDER TABLE Order-No. Order-date... PRODUCT TABLE Product-No. Description... ORDER-LINES Order-No. Product-No. Quantity Composite Primary Key 7 Class and Sub Class create separate tables for the class and each sub class the class table contains only attributes that are common to all subclasses plus a sub class definition column the sub class table contains the and only attributes common to that sub class the s for the class and subclass tables are the same 8 Class / Sub class example sub class definition STUDENT Reg-No. Name U/Grad P/Grad address UNDERGRADUATE Reg-No. Year of Study Course Primary Keys POSTGRADUATE Reg-No. Program 9

Students Example used for next section on Normalisation Registration Student_ID Course_ID Exam_Grade Taken on by Course Course_ID Course_Title Tutor_Name Register on Students Student_ID Student_Name Campus_Address Core_Subject teaches on Tutor Tutor_Name Tutor_Room 10 Normalisation The process of decomposing complex data structures into simple relations according to a set of dependency rules. A step-by-step process used to decompose complex data structures into simple entities (Dowling) 11 Normalisation Organising data into tables (files) to minimise data repetition e.g. Deletion - if student 12347 withdrew from course we would loose BUS fee information Student- Course Fee Reg-No. 12345 ISM 4000 12346 MBA 3500 12347 BUS 4200 12348 ISM 4000 12349 MBA 3500 Insertion - A new course cannot be added until a student registers Redundancy -course fee repeated Updating - If MBA fee changed we would have to alter records of all MBA students 12

Normalised Normalising the data gives Student Course Reg.No. 12346 MBA 12345 IS M 12347 BUS Course Fee MBA 3500 IS M 4000 BUS 4200 Now easy to insert or delete students/course also update fees requires only one amendment BUT may take longer to execute queries 13 The First Normal Form (1NF) (refer to handout) Analyse functional dependencies i.e. the relationship between two attributes Student-ID -> Student_Name, Campus_Address, Core_Subject Course-ID -> Course_Title, Tutor_Name, Tutor_Location Student-ID,Course-ID -> Exam_Grade i.e sort out which attributes uniquely depend on other attributes. the independent attribute becomes the key for the 2NF tables. e.g. Student_ID and Course_ID 14 Student_ID Student_Name Campus_Address Core_Subject Course_ID Course_Title Tutor_Name Tutor_Room Exam_Grade 268300458 Munro 213 Ash ISM ISO6 Relational Databases Baxter 3X9 B ISO3 Java Programming Marshall 4A126 A 543291073 Jackson 432 Spruce QM QM2 Total Quality Management Bentley 3A54 D QM1 Quality Function Deployment Kanji 4B98 C QM7 Quality standards Seddon 3A67 A Unnormalised Student_ID Student_Name Campus_Address Core_Subject Course_ID Course_Title Tutor_Name Tutor_Room Exam_Grade 268300458 Munro 213 Ash ISM ISO6 Relational Databases Baxter 3X9 B 268300458 Munro 213 Ash ISM ISO3 Java Programming Marshall 4A126 A 543291073 Jackson 432 Spruce QM QM2 Total Quality Management Bentley 3A54 D 543291073 Jackson 432 Spruce QM QM1 Quality Function Deployment Kanji 4B98 C 543291073 Jackson 432 Spruce QM QM7 Quality standards Seddon 3A67 A Normalised (1NF) COURSE_DETAILS Course_ID Course_Title Tutor_Name ISO6 Relational Databases Baxter COURSE_TUTOR Course_ID Course_Title Tutor_Name Tutor_Room ISO3 Java Programming Marshall ISO6 Relational DatabaseBaxter 3X9 QM2 Total Quality Management Bentley ISO3 Java Programming Marshall 4A126 QM1 Quality Function Deployment Kanji QM2 Total Quality ManagBentley 3A54 QM7 Quality standards Seddon COURSE_TUTOR splits into QM1 Quality Function De Kanji 4B98 3rd Normal Form (3NF) QM7 Quality standards Seddon 3A67 2nd Normal Form (2NF) TUTOR_DETAILS Tutor_Name Tutor_Room Baxter 3X9 Marshall 4A126 Bentley 3A54 REGISTRATION Student_ID Course_ID Exam_Grade Kanji 4B98 268300458 ISO6 B Seddon 3A67 268300458 ISO3 A 3rd Normal Form (3NF) 543291073 QM2 D 543291073 QM1 C 543291073 QM7 A 3rd Normal Form (3NF) STUDENT Student_ID Student_Name Campus_Address Core_Subject 268300458 Munro 213 Ash ISM 543291073 Jackson 432 Spruce QM 3rd Normal Form (3NF) 15

Second Normal Form (2NF) Create three new relations (tables) from the first normal form (1NF) Organise the attributes into tables, the table key value directly or indirectly determines attribute values e.g. Student, Course_Tutor and Exam_Result This results in 2NF relations (or tables) as shown (N.B two of the relations are already in third normal form) 16 2NF (contd) The table Course_Tutor is still in 2NF because it is still open to the problems discussed earlier i.e. insertion problems ; its difficult to add a new tutor update problems ; Tutor_Location must be changed a number of times deletion problems ; if we delete course QM2 from the table (and it is the only row) we may lose the information that instructor Bentley is located in 3A54 17 Course_Tutor Course_ID Course_Title Tutor_Name Tutor_Room ISO6 Relational Databases Baxter 3X9 ISO3 Java Programming Marshall 4A126 QM2 Total Quality Management Bentley 3A54 QM1 Quality Function Deployment Kanji 4B98 QM7 Quality standards Seddon 3A67 Second Normal Form Course Course_ID Course_Title Tutor_Name ISO6 Relational Databases Baxter ISO3 Java Programming Marshall QM2 Total Quality Management Bentley QM1 Quality Function Deployment Kanji QM7 Quality standards Seddon Third Normal Form Tutor Tutor_Name Tutor_Room Baxter 3X9 Marshall 4A126 Bentley 3A54 Kanji 4B98 Seddon 3A67 Third Normal Form 18

Third Normal Form (3NF) the removal of transient dependencies results in the third normal form (3NF) divide Course_Tutor into two tables as shown Tutor_Name becomes a foreign key i.e. an attribute which is a non-key in one table (like Course) and a primary key in another table (like Tutor) the foreign key is indicated by underlining with a dashed line The normalisation process is now complete 19