Week 8 - answer. Exercise Normalise this data on outstanding video rentals Describe your result as an ER model (relationships not foreign keys) Source:

Slides:



Advertisements
Similar presentations
FEN Introduction to the database field: Quality checking table design: Design Guidelines Normalisation Seminar: Introduction to relational.
Advertisements

Relational Databases Chapter 4.
Logical Data Modeling Review Lecture for University of Agder, Grimstad DAT202 Databaser (5.5.11) Judith Molka-Danielsen
Maintenance Modifying the data –Add records –Delete records –Update records Modifying the design –Add fields into tables –Remove fields from a table –Change.
Week 12 Prizes, PHP and XML Data Schemas and Applications.
Design Guidelines Normalisation Table Design. Informal Design Guidelines Table Semantics A table should hold information about one and only one entity/concept.
Data Modelling. EAR model This modelling language allows a very small vocabulary: Just as English has nouns, verbs, adjectives, pronouns.., EAR models.
Data modelling uses two main techniques Entity relationship (E-R) modelling: a top- down approach Normalisation: a bottom-up approach.
Mapping of N:M Relationships PERSON-ID TITLE PERSON-NAME DATE-OF-BIRTH PERSON-ID PROJECT-ID HOURS-SPENT PROJECT-ID END-DATE START-DATE E-R Diagram PERSON.
Database Design Concepts INFO1408 Term 2 week 1 Data validation and Referential integrity.
Relational Data Analysis II. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.
Database – Part 2a Dr. V.T. Raja Oregon State University.
Relational Databases What is a relational database? What would we use one for? What do they look like? How can we describe them? How can you create one?
Chapter 4 Relational Databases Copyright © 2012 Pearson Education 4-1.
Introduction to Schema Refinement. Different problems may arise when converting a relation into standard form They are Data redundancy Update Anomalies.
Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall 1 1. Chapter 2: Relational Databases and Multi-Table Queries Exploring Microsoft Office.
2.3 Organising Data for Effective Retrieval
1 Introduction to modeling Relational modelling Slides for this part are based on Chapters 11 from Halpin, T. & Morgan, T. 2008, Information Modeling and.
Modelling Techniques - Normalisation Description and exemplification of normalisation.Description and exemplification of normalisation. Creation of un-normalised.
Web Application Development. Define ER model in QSEE Generate SQL Create Database mySQL Write Script to use TableEditor class Process to create A simple.
Web Application Development. Tools to create a simple web- editable database QSEE MySQL (or PHPMyAdmin) PHP TableEditor.
DAY 15: ACCESS CHAPTER 2 Larry Reaves October 7,
Relational Database Concepts. Let’s start with a simple example of a database application Assume that you want to keep track of your clients’ names, addresses,
Driving School Database
MIS 301 Information Systems in Organizations Dave Salisbury ( )
MIS 301 Information Systems in Organizations Dave Salisbury ( )
Concepts of Relational Databases. Fundamental Concepts Relational data model – A data model representing data in the form of tables Relations – A 2-dimensional.
CORE 2: Information systems and Databases NORMALISING DATABASES.
U:/msu/course/cse/103 Day 07, Slide 1 Day 15 Review What datatype would be an appropriate choice for: –A cell phone number.
Normalization Well structured relations and anomalies Normalization First normal form (1NF) Functional dependence Partial functional dependency Second.
Information Systems & Databases 2.2) Organisation methods.
© Relational Databases. © Entities Data is stored in tables. Each table is concerned with one entity An entity is a.
Database Design. Referential Integrity : data in a table that links to data in another table must always work in such a way that following the link will.
Database Systems: Design, Implementation, and Management Tenth Edition Chapter 4 Entity Relationship (ER) Modeling.
Revision Instructor: Mohamed Eltabakh 1.
3 & 4 1 Chapters 3 and 4 Drawing ERDs October 16, 2006 Week 3.
Copyright 2006 Prentice-Hall, Inc. Essentials of Systems Analysis and Design Third Edition Joseph S. Valacich Joey F. George Jeffrey A. Hoffer Chapter.
Copyright 2007, Paradigm Publishing Inc. ACCESS 2007 Chapter 2 BACKNEXTEND 2-1 LINKS TO OBJECTIVES Creating Related Tables Creating Related Tables Determining.
Database Application Design and Data Integrity AIMS 3710 R. Nakatsu.
PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition Copyright © 2009 John Wiley & Sons, Inc. All rights.
An Entity Relationship (ER) Diagram is a graphic that shows the interrelationship between entities in a database.
Chapter 9 Logical Database Design : Mapping ER Model To Tables.
Advanced Accounting Information Systems Day 10 answers Organizing and Manipulating Data September 16, 2009.
©NIIT Normalizing and Denormalizing Data Lesson 2B / Slide 1 of 18 Objectives In this section, you will learn to: Describe the Top-down and Bottom-up approach.
Quiz questions. 1 A data structure that is made up of fields and records? Table.
Database Design Normalisation. Last Session Looked at: –What databases were –Where they are used –How they are used.
MIS 301 Information Systems in Organizations Dave Salisbury ( )
The relational model A data model (in general) : Integrated collection of concepts for describing data (data requirements). Relational model was introduced.
Constraints Lesson 8. Skills Matrix Constraints Domain Integrity: A domain refers to a column in a table. Domain integrity includes data types, rules,
1 ER Modeling BUAD/American University Mapping ER modeling to Relationships.
Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall Chapter 9 Designing Databases 9.1.
Data modeling Process. Copyright © CIST 2 Definition What is data modeling? –Identify the real world data that must be stored on the database –Design.
Conceptual Design to Logical Design Lecture 4. Aims  To introduce Business Rules  To identify what a Business Rule is  To Introduce Business Operations.
Tutorial 2 Data Modelling. 3 Terminology & Notation(1) An entity is an object about which the system needs to hold information –Customer, Student, Course.
Sample Table Standard Notation Entity name in uppercase
Description and exemplification use of a Data Dictionary. A data dictionary is a catalogue of all data items in a system. The data dictionary stores details.
Chapter 3: Relational Databases
Information Systems Database Systems (H).
1 CS 430 Database Theory Winter 2005 Lecture 7: Designing a Database Logical Level.
FEN Introduction to the database field: The development process Seminar: Introduction to relational databases Development process: Analyse.
Logical Database Design and Relational Data Model Muhammad Nasir
Lecture 5 Data Model Design Jeffery S. Horsburgh Hydroinformatics Fall 2012 This work was funded by National Science Foundation Grant EPS
Normalisation Unit 6: Databases. Just to recap  What is an Entity  What is an Attribute?
NORMALISATION OF DATABASES. WHAT IS NORMALISATION? Normalisation is used because Databases need to avoid have redundant data, which makes it inefficient.
Dr Gordon Russell, Napier University Normalisation 1 - V2.0 1 Normalisation 1 Unit 3.1.
Database Keys and Constraints
Data Modelling Introduction
Chapter 4.1 V3.0 Napier University Dr Gordon Russell
Introduction to modeling
Normalisation 1 Unit 3.1 Dr Gordon Russell, Napier University
Presentation transcript:

Week 8 - answer

Exercise Normalise this data on outstanding video rentals Describe your result as an ER model (relationships not foreign keys) Source:

Normalisation Video data –Artist is the same for a given video title –So is Length –So these depend only on Video Title –So normalise this data into one table: Video with a primary key of VideoTitle Borrower data –Borrower(name) and Card Nbr are related –So Normalise to a Borrower table with a primary key of CardNbr What remains is –DateDue, DaysOverdue, VideoTitle, CopyNbr and CardNbr –These represent a Rental –Primary key is VideoTitle, CopyNbr, and Date (why not CardNbr?)

Normalised Tables Video(VideoTitle, Artist, Length) Borrower (CardNbr, Name) Rental (VideoTitle, CopyNbr, DateDue, DaysOverdue, CardNbr)

CopyNbr not unique in the shop but only for a VideoTitle This indicates Foreign Key becomes part of the PrimaryKey ER model

Observations We can improve on this model in two ways: –When a video is returned, the rental record will be deleted. But this will also delete knowledge of the existence of a video copy, so we need to introduce a Copy table –The DaysOverdue is actually a function of today’s date and the due date- today seems to be 8/32/00 (i.e.9/1/00) so this data is redundant since it can be calculated –In UML you would be able to keep this attribute but mark it as derived and define the rule for calculating it. –This model is closer to the model you might create working top-down

CREATE TABLE Video( TitleVARCHAR(20) NOT NULL, ArtistVARCHAR(20), LengthINTEGER, CONSTRAINTpk_Video PRIMARY KEY (Title) ); CREATE TABLE Borrower( CardNbrINTEGER NOT NULL, BorrowerNameVARCHAR(8), CONSTRAINTpk_Borrower PRIMARY KEY (CardNbr) ); CREATE TABLE Rental( DueDateDATE NOT NULL, CopyNbrINTEGER NOT NULL, TitleVARCHAR(20) NOT NULL, CONSTRAINTpk_Rental PRIMARY KEY (DueDate,CopyNbr,Title) ); CREATE TABLE Copy( CopyNbrINTEGER NOT NULL, TitleVARCHAR(20) NOT NULL, CONSTRAINTpk_Copy PRIMARY KEY (CopyNbr,Title) ); Create LINK tables -- CREATE TABLE Borrower_Rental( CardNbrINTEGER NOT NULL, DueDateDATE NOT NULL, CopyNbrINTEGER NOT NULL, TitleVARCHAR(20) NOT NULL, PRIMARY KEY (DueDate,CopyNbr,Title), FOREIGN KEY(CardNbr) REFERENCES Borrower(CardNbr) ON DELETE RESTRICT ON UPDATE RESTRICT, FOREIGN KEY(DueDate,CopyNbr,Title) REFERENCES Rental(DueDate,CopyNbr,Title) ON DELETE RESTRICT ON UPDATE RESTRICT );

QSEE code generation Note the additional link table. This is because Borrower is optional (the second entry in the sample data). QSEE is very strict about forbidding nulls as foreign keys, so it creates an addition link table. Nulls in foreign key fields is a big debating point – theorists on the one side, pragmatists on the other. In my view QSEE should allow this as a optional setting. The only way to avoid this additional table is to remove the optionality, generate the DDL and then edit the foreign key column to remove the ‘Not Null’ constraint from the foreign key column.

Questions for the customer Is VideoTitle really unique? Can two videos have the same title? Is there a standard identifier like ISBN which would be better? How could this be linked to IMDb e.g. Out of AfricaOut of Africa Numbering copies of a title is a bit harder than numbering every copy with a serial number which is unique in the store. Would this be a better approach?