Consolidation Objectives of the Lecture : To review a given design of a relational database. To amplify the design by adding Integrity Constraints. To.

Slides:



Advertisements
Similar presentations
Active database concepts
Advertisements

Data Definition and Integrity Constraints
POSTGRESQL DUNGEON WITH TABLE INHERITANCE AND CONSTRAINTS Edel Sherratt.
Transform an ER Model into a Relational Database Schema
MSc IT UFCE8K-15-M Data Management Prakash Chatterjee Room 2Q18
IS698: Database Management Min Song IS NJIT. The Relational Data Model.
Referential Integrity & Foreign Keys Objectives of the Lecture : To consider Referential Integrity & Foreign Keys; To consider Referential Integrity Constraints.
Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 5/1 Copyright © 2004 Please……. No Food Or Drink in the class.
SQL Lecture 10 Inst: Haya Sammaneh. Example Instance of Students Relation  Cardinality = 3, degree = 5, all rows distinct.
BIS Database Systems School of Management, Business Information Systems, Assumption University A.Thanop Somprasong Chapter # 6 Advanced Data Modeling.
Candidate Keys Objectives of the Lecture : To consider Integrity Constraints; To consider the principles of Candidate Keys; To consider Candidate Keys.
Normalisation Ensuring data integrity in database design 1.
Maintenance Modifying the data –Add records –Delete records –Update records Modifying the design –Add fields into tables –Remove fields from a table –Change.
Chapter 3 The Relational Model Transparencies © Pearson Education Limited 1995, 2005.
Chapter 6 Methodology Logical Database Design for the Relational Model Transparencies © Pearson Education Limited 1995, 2005.
Fundamentals, Design, and Implementation, 9/e Chapter 5 Database Design.
Chapter 3. 2 Chapter 3 - Objectives Terminology of relational model. Terminology of relational model. How tables are used to represent data. How tables.
Database Design Concepts INFO1408 Term 2 week 1 Data validation and Referential integrity.
SQL DDL constraints Restrictions on the columns and tables 1SQL DDL Constraints.
Week 2 Lecture 2 Structure of a database. External Schema Conceptual Schema Internal Schema Physical Schema.
Using ERWin to model your data Supplied by Computer Associates as part of AllFusion.
July 14, 2015ICS 424: recap1 Relational Database Design: Recap of ICS 324.
Copyright ©2014 Pearson Education, Inc. Chapter 3 Requirements and Business Rules Chapter3.1.
Database Constraints. Database constraints are restrictions on the contents of the database or on database operations Database constraints provide a way.
Lecture 2 The Relational Model. Objectives Terminology of relational model. How tables are used to represent data. Connection between mathematical relations.
Relational Model Session 6 Course Name: Database System Year : 2012.
Database Management System Lecture 6 The Relational Database Model – Keys, Integrity Rules.
Learningcomputer.com SQL Server 2008 – Entity Relationships in a Database.
Mark Dixon Page 1 23 – Web applications: Writing data to Databases using PhP.
Constraints  Constraints are used to enforce rules at table level.  Constraints prevent the deletion of a table if there is dependencies.  The following.
1 CSE 480: Database Systems Lecture 5: Relational Data Model.
Lecture 7 Integrity & Veracity UFCE8K-15-M: Data Management.
Ad Hoc Constraints Objectives of the Lecture : To consider Ad Hoc Constraints in principle; To consider Ad Hoc Constraints in SQL; To consider other aspects.
Object Oriented Analysis and Design 1 Chapter 7 Database Design  UML Specification for Data Modeling  The Relational Data Model and Object Model  Persistence.
DATABASE MGMT SYSTEM (BCS 1423) Chapter 5: Methodology – Conceptual Database Design.
Amendments & Transactions Objectives of the Lecture : To consider amendments to a relation; To consider transactions in SQL.
Chapter No 4 Query optimization and Data Integrity & Security.
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.
Module 3 Designing and Implementing Tables. Module Overview Designing Tables Working with Schemas Creating and Altering Tables.
Dec 8, 2003Murali Mani Constraints B term 2004: lecture 15.
Chapter 9 Constraints. Chapter Objectives  Explain the purpose of constraints in a table  Distinguish among PRIMARY KEY, FOREIGN KEY, UNIQUE, CHECK,
Oracle 11g: SQL Chapter 4 Constraints.
Chapter 4 Constraints Oracle 10g: SQL. Oracle 10g: SQL 2 Objectives Explain the purpose of constraints in a table Distinguish among PRIMARY KEY, FOREIGN.
1 DBS201: More on SQL Lecture 3. 2 Agenda How to use SQL to update table definitions How to update data in a table How to join tables together.
The Relational Model. 2 Relational Model Terminology u A relation is a table with columns and rows. –Only applies to logical structure of the database,
Conceptual Design to Logical Design Lecture 4. Aims  To introduce Business Rules  To identify what a Business Rule is  To Introduce Business Operations.
MIS 3053 Database Design And Applications The University Of Tulsa Professor: Akhilesh Bajaj Normal Forms Lecture 1 © Akhilesh Bajaj, 2000, 2002, 2003.
Further Consolidation Objectives of the Lecture : To use simple queries to check out a DB. To use insertions, deletions and amendments to maintain a DB.
Mapping ER to Relational Model Each strong entity set becomes a table. Each weak entity set also becomes a table by adding primary key of owner entity.
Chapter 3 The Relational Model. Objectives u Terminology of relational model. u How tables are used to represent data. u Connection between mathematical.
Methodology - Logical Database Design. 2 Step 2 Build and Validate Local Logical Data Model To build a local logical data model from a local conceptual.
SCUHolliday - coen 1789–1 Schedule Today: u Constraints, assertions, triggers u Read Sections , 7.4. Next u Embedded SQL, JDBC. u Read Sections.
Chapter 4 The Relational Model Pearson Education © 2009.
1 CS122A: Introduction to Data Management Lecture #4 (E-R  Relational Translation) Instructor: Chen Li.
Database Constraints Ashima Wadhwa.
Chapter 5 Database Design
COP 4540 Database Management
SQL Creating and Managing Tables
Database Systems Instructor Name: Lecture-12.
Module 5: Implementing Data Integrity by Using Constraints
COS 346 Day 8.
SQL Creating and Managing Tables
Lecturer: Mukhtar Mohamed Ali “Hakaale”
Normalization Referential Integrity
SQL Creating and Managing Tables
Lesson Objectives Aims You should know about: 1.3.2: (a) indexing (d) SQL – Interpret and Modify (e) Referential integrity (f) Transaction processing,
SQL – Constraints & Triggers
INTRODUCTION A Database system is basically a computer based record keeping system. The collection of data, usually referred to as the database, contains.
Presentation transcript:

Consolidation Objectives of the Lecture : To review a given design of a relational database. To amplify the design by adding Integrity Constraints. To translate that design into SQL Create Table statements.

‘The University Database’ l The start point is an initial design, already provided, for a ‘University DB’ of 4 relations. l Each relation will be reviewed to see what integrity constraints should be applied to it. l The possible integrity constraints are : Attribute Data Types, Candidate Keys, Referential Integrity, Ad Hoc Constraints. l The review will determine what integrity constraints need to be added to the initial design to complete it. l The completed design will then be translated into 4 SQL Create Table statements, one for each relation.

‘STUDENT’ Relation Stud_NoSnameFnameStatusCourse S1254JonesJaneHBIS T2532RobertsElizabethHGames S5568JarvisAndrewHITMB T1125FletcherNigelHITMB T2289EvansTomasOBIS J4452BrownCharlieHBIT S9889GreenGillOBIT Meaning : A student exists, identified by the ID ‘S1254’, Surname ‘Jones’, Forename ‘Jane’, whose Status is ‘H’ & who is on the ‘BIS’ course, and so on for all the students.

Integrity Constraints for ‘STUDENT’ l Decide on the Data Type for every attribute. l Decide on the Candidate Keys, how many are there, and which attributes does each Candidate Key contain. l Decide on any necessary Ad Hoc Constraints, to ensure physical reality, to keep ‘Business Rules’, to specify a specific data type based on an underlying type,.... ? l Referential Integrity. Requires consideration of 2 or more relations – so leave till all the relations have been specified. Apply the same procedure to every relation.

Course ID SchoolC_LeaderDuration BISCEISIZGG14 GamesCEISCGDH23 ITMBCEISIZAT13 BITCEISCGGE14 ‘COURSE’ Relation Meaning : A course exists, identified by the ID ‘BIS’, run by the ‘CEIS’ School, whose Course Leader has the ID ‘IZGG1’, & whose Duration is ‘4’ years, and so on for all the courses.

CodeNameTutor CM0429Relational DatabasesCGDL1 CG0401Introduction to Business Systems IZAT1 ‘MODULE’ Relation Meaning : A module exists, identified by the code ‘CM0429’, named ‘Relational Databases’, & whose Module Tutor has the ID ‘CGDL1’, and so on for all the modules.

CourseModule ITMBCM0429 BISCG0401 ITMBCG0401 GamesCM0429 BITCM0429 BITCG0401 ‘COURSE_CONTENT’ Relation Meaning : A ‘course content’ item exists, consisting of a course whose name is ‘ITMB’ with a module identified by the code ‘CM0429’, and so on for all the course content items.

Referential Integrity l Taking every possible pair of relations in turn, are there any attributes, or sets of attributes, such that the attribute values, or sets of attribute values, in one relation should appear in another relation ? Example : every Course attribute value held in the STUDENT relation should appear as a value in the Course ID attribute of the COURSE relation, otherwise there is a student on a non-existant course. l The attributes are not required to have the same names in the 2 relations; they must have the same data types, or we are not comparing ‘like with like’.

Foreign Keys l In Referential Integrity, a Foreign Key ‘refers’ to a Candidate Key. Example : the Course attribute in STUDENT refers to the Course ID attribute in COURSE, so Course is a Foreign Key referring to Course ID. l It can be useful to check whether the set of Foreign Key values (i.e. ignoring any duplicate values) should be the same as the set of Candidate Key values, or could be a subset of them. Example : if the set of different Course attribute values in STUDENT is a subset of the different Course ID attribute values in COURSE, then not every course has students on it. Is this OK ?

SQL Tables l Decide on the most appropriate SQL Data Type for each attribute. l If there is more than one Candidate Key, decide which one will be the Primary Key in SQL. l Decide on the CHECK constraints required to implement any Ad Hoc constraints. l Decide which Foreign Keys will reference which Primary Keys. (Note that SQL does not allow Foreign Keys to reference Alternate Keys). Decide which order to create the tables in. A Foreign Key cannot reference a Primary Key which does not yet exist ! In a ‘CATCH-22’ situation, create the tables without Foreign Keys, & add the Foreign Keys after with Alter Table statements.

Conclusion l The SQL Create Table (& any Alter Table) statements derived in the lecture will be used in the practical sessions to actually create ‘The University DB’ which will consist of these 4 SQL tables. l Use the example of ‘The University DB’ to review the DB created in previous practical sessions and resolve any issues outstanding.