Keys  SuperKey  a set of attributes whose values together uniquely identify a tuple in a relation  Candidate Key  a superkey for which no proper subset.

Slides:



Advertisements
Similar presentations
Relational data integrity
Advertisements

Normalisation. Informal guidelines  Semantics of the attributes  easy to explain relation  doesn’t mix concepts  Reducing the redundant values in.
Relational Database. Relational database: a set of relations Relation: made up of 2 parts: − Schema : specifies the name of relations, plus name and type.
Relational Model (CB Chapter 4) CPSC 356 Database Ellen Walker Hiram College.
SQL Lecture 10 Inst: Haya Sammaneh. Example Instance of Students Relation  Cardinality = 3, degree = 5, all rows distinct.
Assignment6-1 Assignment6-2 Due Wednesday, March 13 1.
Chapter 3 The Relational Model Transparencies © Pearson Education Limited 1995, 2005.
Chapter 3. 2 Chapter 3 - Objectives Terminology of relational model. Terminology of relational model. How tables are used to represent data. How tables.
Relational Model Stores data as tables –Each column contains values about the same attribute –Each column has a distinct name –Each row contains values.
1 Relational Model. 2 Relational Database: Definitions  Relational database: a set of relations  Relation: made up of 2 parts: – Instance : a table,
Thomas Connolly and Carolyn Begg’s
Database Systems Relational Model Concepts Toqir Ahmad Rana Database Management Systems 1 Lecture 17.
Database Architecture The Relational Database Model.
Data Definition, Relational Manipulation and Data Control Using SQL.
CSC271 Database Systems Lecture # 6. Summary: Previous Lecture  Relational model terminology  Mathematical relations  Database relations  Properties.
Lecture 2 The Relational Model. Objectives Terminology of relational model. How tables are used to represent data. Connection between mathematical relations.
Chapter 4 The Relational Model Pearson Education © 2014.
© Pearson Education Limited, Chapter 2 The Relational Model Transparencies.
Relational Model Session 6 Course Name: Database System Year : 2012.
Chapter 4 The Relational Model.
Relational Data Model. A Brief History of Data Models  1950s file systems, punched cards  1960s hierarchical  IMS  1970s network  CODASYL, IDMS 
1 More on ER Model Detail Relationships 4. 2 Attributes  Attribute  A property or characteristic of an entity type that is of interest to the organisation.
RAJIKA TANDON DATABASES CSE 781 – Database Management Systems Instructor: Dr. A. Goel.
Introduction to Database Systems Mapping ER Models to Relational Schemas Irvanizam Zamanhuri, M.Sc Informatics (Computer Science) Study Program Syiah Kuala.
The Relational Model Database Systems Lecture 3 Natasha Alechina.
Keys  SuperKey  a set of attributes whose values together uniquely identify a tuple in a relation  Candidate Key  a superkey for which no proper subset.
Chapter 3 The Relational Model. 2 Chapter 3 - Objectives u Terminology of relational model. u How tables are used to represent data. u Connection between.
R ELATIONAL D ATA M ODEL Joe Meehean 1. R ELATIONAL D ATA M ODEL Data stored as a set of relations really just tables Tables related to one another through.
Database Systems Lecture # 7 8 th Feb, Conceptual and Logical Design Person buys Product name pricenamessn Conceptual Model: Relational Model: (plus.
(Extended) Entity Relationship Modelling and Mappings to the Relational Data Model.
Normalization (Codd, 1972) Practical Information For Real World Database Design.
1 The Relational Database Model. 2 Learning Objectives Terminology of relational model. How tables are used to represent data. Connection between mathematical.
Slide Chapter 5 The Relational Data Model and Relational Database Constraints.
Module Coordinator Tan Szu Tak School of Information and Communication Technology, Politeknik Brunei Semester
Announcements Reading for Monday –4.6 Homework 3 – Due 9/29.
1 Web Database The Relational Data Model Irvanizam Zamanhuri, M.Sc Computer Science Study Program Syiah Kuala University Website :
1 CS 430 Database Theory Winter 2005 Lecture 4: Relational Model.
Copyright © 2011 by Michael V. Mannino All rights reserved. Database Design, Application Development, and Administration, 5 th Edition Quiz G4 Hyunwoo.
1 ER Modeling BUAD/American University Mapping ER modeling to Relationships.
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,
CS34311 The Relational Model. cs34312 Why Relational Model? Currently the most widely used Vendors: Oracle, Microsoft, IBM Older models still used IBM’s.
CS 3630 Database Design and Implementation. Null Value The value of an attribute could be NULL NOT known at the moment or NOT Applicable Example Cell.
April 20022CS3X1 Database Design The relational model John Wordsworth Department of Computer Science The University of Reading
Lecture 03 Constraints. Example Schema CONSTRAINTS.
CHAPTER 2 : RELATIONAL DATA MODEL Prepared by : nbs.
The Relational Model © Pearson Education Limited 1995, 2005 Bayu Adhi Tama, M.T.I.
The relational model1 The relational model Mathematical basis for relational databases.
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.
Week 2 Lecture The Relational Database Model Samuel ConnSamuel Conn, Faculty Suggestions for using the Lecture Slides.
Chapter 4 The Relational Model Pearson Education © 2009.
1 CS122A: Introduction to Data Management Lecture #4 (E-R  Relational Translation) Instructor: Chen Li.
Simplified phases of Database Design
The Relational Data Model and Relational Database Constraints
RELATION.
CIS 207 The Relational Database Model
Lecture # 13 (After 1st Exam)
Views.
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 4 The Relational Model Pearson Education © 2009.
02 - The Relational Database Model
The Relational Model Transparencies
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 4 The Relational Model Pearson Education © 2009.
Practical Relevance Examples Class Laboratory
Chapter 4 The Relational Model Pearson Education © 2009.
INSTRUCTOR: MRS T.G. ZHOU
Views.
Presentation transcript:

Keys  SuperKey  a set of attributes whose values together uniquely identify a tuple in a relation  Candidate Key  a superkey for which no proper subset is a superkey…a key that is minimal.  Can be more than one for a relation  Primary Key  a candidate key chosen to be the main key for the relation.  One for each relation  Keys can be composite

e.g.: Staff(lecturer,roomno,appraiser) SK = {lecturer,roomno,appraiser}, {lecturer,roomno}, {lecturer, appraiser}, {roomno,appraiser}, {lecturer} and {roomno} CK = {lecturer} and {roomno} PK = {lecturer}

Foreign Key  a (set of) attribute(s) in a relation that exactly matches a (primary) key in another relation  the names of the attributes don’t have to be the same but must be of the same domain  a foreign key in a relation A matching a primary key in a relation B represents a  many:one relationship between A and B Student(studno,name,tutor,year) Staff(lecturer,roomno,appraiser)

Relationship -v- Relation SCHOOL REG m 1 name STUDENT studno faculty hons STUDENT (studno, name, hons) SCHOOL(hons, faculty) Relationship Relation (table) “an association between several entities represented by a Relationship Type of which there will be many Relationship Instances”

Relationship -v- Relation COURSE exammark ENROL m n name STUDENT studno subject courseno STUDENT (studno, name) ENROL(studno, courseno,exammark) COURSE(courseno, subject) ENROL Relation ENROL Relationship

STUDENT studnonametutor s1jonesbush s2brownkahn s3smithgoble STAFF lecturerroomno kahnIT206 bush2.26 Joins e.g., get studno, name and tutor’s roomno for each student

STUDENT studnonametutor s1jonesbush s2brownkahn s3smithgoble STAFF lecturerroomno kahnIT206 bush2.26

STUDENT studnonametutor s1jonesbush s2brownkahn s3smithgoble STAFF lecturerroomno kahnIT206 bush2.26 studnonametutor s1jonesbush s2brownkahn s3smithbush lecturerroomno kahnIT206 bush2.26 s1jonesbush s2brownkahn IT206 bush2.26 kahnIT206 bush2.26 s3smithbush SELECT FROM STUDENT a, STAFF b WHERE  studno,name,roomno (STUDENT tutor=lecturer STAFF)

STUDENT studnonametutor s1jonesbush s2brownkahn s3smithgoble STAFF lecturerroomno kahnIT206 bush2.26 studnonametutor s1jonesbush s2brownkahn s3smithbush lecturerroomno kahnIT206 bush2.26 s1jonesbush s2brownkahn IT206 bush2.26 kahnIT206 bush2.26 s3smithbush SELECT FROM STUDENT a, STAFF b WHERE a.tutor=b.lecturer  studno,name,roomno (STUDENT tutor=lecturer STAFF)

STUDENT studnonametutor s1jonesbush s2brownkahn s3smithgoble STAFF lecturerroomno kahnIT206 bush2.26 studnonametutor s1jonesbush s2brownkahn s3smithbush lecturerroomno kahnIT206 bush2.26 s1jonesbush s2brownkahn IT206 bush2.26 kahnIT206 bush2.26 s3smithbush SELECT a.studno, a.name, b.roomno FROM STUDENT a, STAFF b WHERE a.tutor=b.lecturer  studno,name,roomno (STUDENT tutor=lecturer STAFF)

STUDENT studnonametutor s1jonesbush s2brownkahn s3smithgoble STAFF lecturerroomno kahnIT206 bush2.26 studnonametutor s1jonesbush s2brownkahn s3smithbush lecturerroomno kahnIT206 bush2.26 s1jonesbush s2brownkahn IT206 bush2.26 kahnIT206 bush2.26 s3smithbush SELECT a.studno, a.name, b.roomno FROM STUDENT a, STAFF b WHERE a.tutor=b.lecturer and studno=‘s1’  studno=‘s1’ (  studno,name,roomno (STUDENT tutor=lecturer STAFF) )

Join as Path HOTEL (hotelid, name, resort) RESORT(resort, region) REGION(region,country) Get hotels and their regions Residences m Hotel hotelid Resort resort RegLoc m Region region 11 SELECT FROM WHERE

HOTEL (hotelid, name, resort) RESORT(resort, region) REGION(region,country) Get hotels and their regions Residences m Hotel hotelid Resort resort RegLoc m Region region 11 SELECT FROM HOTEL, RESORT, REGION WHERE

HOTEL (hotelid, name, resort) RESORT(resort, region) REGION(region,country) Get hotels and their regions Residences m Hotel hotelid Resort resort RegLoc m Region region 11 SELECT FROM HOTEL, RESORT, REGION WHERE hotel.resort=resort.resort

HOTEL (hotelid, name, resort) RESORT(resort, region) REGION(region,country) Get hotels and their regions Residences m Hotel hotelid Resort resort RegLoc m Region region 11 SELECT FROM HOTEL, RESORT, REGION WHERE hotel.resort=resort.resort and resort.region=region.region hotel.resort=resort.resort resort.region=region.region

HOTEL (hotelid, name, resort) RESORT(resort, region) REGION(region,country) Get hotels and their regions Residences m Hotel hotelid Resort resort RegLoc m Region region 11 SELECT hotel.name, region.region FROM HOTEL, RESORT, REGION WHERE hotel.resort=resort.resort and resort.region=region.region hotel.resort=resort.resort resort.region=region.region

Sub and Super-Types (Classes) name given family STUDENT studno d undergraduate postgraduate   thesis title year undergraduate postgraduate STUDENT brown jones

Sub and Super-Types (Classes) name given family PERSON o staff student   staff student PERSON brown

Sub and Super-Types (Classes) STAFF o technical admin   technical STAFF smith

Referential Integrity  Student(studno,name,tutor,year)  Staff(lecturer,roomno,appraiser)  CASCADE  delete all matching foreign key tuples e.g. STUDENT  RESTRICT  can’t delete primary key tuple STAFF whilst a foreign key tuple STUDENT matches  NULLIFY  foreign key STUDENT.tutor set to null if the foreign key ids allowed to take on null

Lab Extensions  Completed work must be handed in by 9:30 on the day of the subsequent lab!