Database Design The Relational Model Text Ch5

Slides:



Advertisements
Similar presentations
The Relational Model Much of the material presented in these slides was developed by Dr. Ramon Lawrence at the University of Iowa.
Advertisements

Defined by Edgar Codd in 1970 Defined by Edgar Codd in 1970 Considered ingenious but impractical Considered ingenious but impractical Conceptually simple.
Relational Database. Relational database: a set of relations Relation: made up of 2 parts: − Schema : specifies the name of relations, plus name and type.
OUTLINE OF THE LECTURE PART I GOAL: Understand the Data Definition Statements in Fig 4.1 Step1: Columns of the Tables and Data types. Step2: Single column.
Exploring Microsoft Access 2003 Chapter 4 Proficiency: Relational Databases, External Data, Charts, Pivot, and the Switchboard.
Chapter 3 The Relational Model Transparencies © Pearson Education Limited 1995, 2005.
Relations The Relational Data Model John Sieg, UMass Lowell.
Chapter 3. 2 Chapter 3 - Objectives Terminology of relational model. Terminology of relational model. How tables are used to represent data. How tables.
- relation schema, relations - database schema, database state
Review Database Application Development Access Database Development ER-diagram Forms Reports Queries.
Relational Database Management System A type of database in which records are stored in relational form is called relational database management system.
Database Architecture The Relational Database Model.
CS 380 Introduction to Database Systems (Chapter 5: The Relational Data Model and Relational Database Constraints)
Relational Model & Relational Algebra. 2 Relational Model u Terminology of relational model. u How tables are used to represent data. u Connection between.
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.
1 Lecture 04 The relational data Model, Relational Constraints 1.
Relational Model Session 6 Course Name: Database System Year : 2012.
1 The Relational Data Model, Relational Constraints, and The Relational Algebra.
Review: Application of Database Systems
Database Management COP4540, SCS, FIU Relational Model Chapter 7.
Instructor: Churee Techawut Basic Concepts of Relational Database Chapter 5 CS (204)321 Database System I.
DatabaseIM ISU1 Fundamentals of Database Systems Chapter 5 The Relational Data Model.
The Relational Data Model and Relational Database Constraints
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.
Ihr Logo Fundamentals of Database Systems Fourth Edition El Masri & Navathe Chapter 5 The Relational Data Model and Relational Database Constraints.
Slide Chapter 5 The Relational Data Model and Relational Database Constraints.
Logical Design database design. Dr. Mohamed Osman Hegaz2 Conceptual Database Designing –Provides concepts that are close to the way many users perceive.
1 CS 430 Database Theory Winter 2005 Lecture 4: Relational Model.
CSE314 Database Systems Lecture 3 The Relational Data Model and Relational Database Constraints Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson.
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,
The Relational Model © Pearson Education Limited 1995, 2005 Bayu Adhi Tama, M.T.I.
Chapter 3 The Relational Model. Objectives u Terminology of relational model. u How tables are used to represent data. u Connection between mathematical.
Chapter 4 The Relational Model Pearson Education © 2009.
1 The Relational Data Model David J. Stucki. Relational Model Concepts 2 Fundamental concept: the relation  The Relational Model represents an entire.
The Relational Data Model & Relational Algebra
Relational Model Database Management Systems, 3rd ed., Ramakrishnan and Gehrke, Chapter 3.
Module 2: Intro to Relational Model
Introduction to Relational Model
Chapter 2: Intro to Relational Model
Chapter (9) ER and EER-to-Relational Mapping, and other Relational Languages Objectives How a relational database schema can be created from a conceptual.
Chapter 3: Intro to Relational Model
Chapter 2: Intro to Relational Model
Chapter 2: Intro to Relational Model
Chapter (9) ER and EER-to-Relational Mapping, and other Relational Languages Objectives How a relational database schema can be created from a conceptual.
376a. Database Design Dept. of Computer Science Vassar College
Chapter 2: Intro to Relational Model
Mapping ER Diagrams to Tables
Outline: Relational Data Model
Data Base System Lecture 6: Relational Model
Company Requirements.
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 4 The Relational Model Pearson Education © 2009.
The Relational Model Transparencies
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 2: Intro to Relational Model
Chapter 2: Intro to Relational Model
Example of a Relation attributes (or columns) tuples (or rows)
Design tools and techniques for a relational database system
Chapter 2: Intro to Relational Model
Chapter 2: Intro to Relational Model
1. Explain the following concepts: (a) superkey (b) key
1.(5) Describe the working process with a database system.
ISC321 Database Systems I Chapter 4: SQL: Data definition, Constraints, and Basic Queries and Updates Fall 2015 Dr. Abdullah Almutairi.
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter (7) ER-to-Relational Mapping, and other Relational Languages
RELATIONAL DATA MODEL - 1
Presentation transcript:

Database Design The Relational Model Text Ch5 Database Design lecture 2 1

In the relational model, data are organized into tables. A table corresponds to the mathematical concept of a relation (come back shortly). The table must have a name (a.k.a the relation name). Each column must have a name, known as an attribute. Each row (not including the table heading row) is called a tuple. If the tuple has n elements then it is called an n-tuple. The number of columns (resp. rows) is called the degree or arity (resp. cardinality) of the relation. Database Design lecture 2 2

Table (Relation) Example 1 A Student table in a university database studentNo Name City Phone 13678765 Barbara Brisbane 44132565 12345678 David Sydney 76354543 16432527 Darren Melbourne 90113422 16543672 Johnson Gold Coast 55224433 Database Design lecture 2 3

Relation Schema and Instance Let R be the name of a relation, and A1,…, An be the attributes. Then R(A1,…, An ) is called the schema of the relation. Each attribute of a relation must have a fixed set from which to obtain values. Eg, Name : the set of all possible names Age: {0, 1, 2,…, 150} The set corresponding to attribute Ai is called the domain of Ai , denoted dom(Ai ). At different times, the relation may contain different tuples. Each possible set of tuples is called a state (or an instance) of the relation. Database Design lecture 2 4

Relational Database Schema and Instance A relational database – a collection of relations. The schemas of the relations collectively (together with a set of integrity constraints – see slide 13) is called the relational database schema. The relations in a database should have distinct names. Attributes within the same relation should have distinct names. A database (instance) consists of the instances (one for each relation) of the relations. Database Design lecture 2 5

Atomic value in each cell Data Inside a Relation Atomic value in each cell The data item in each table cell must be atomic can not be divided into smaller components Atomicity is a relative concept, it depends on the application. A special value NULL can appear in any cell represents unknown value or non-existent value eg, in Student table, a student may have no phone number, or his phone number may be unknown. In such cases, the corresponding value is NULL If t is a tuple, and A is an attribute, then the value of attribute A in t is denoted t[A]. Similarly t[A1, A3] denotes the subtuple of values of the attributes A1 and A3, and so forth. Database Design lecture 2 6

Mathematical Definition of Relations Formally, given sets D1, D2, …. Dn a relation r is a subset of D1 x D2 x … x Dn Thus a relation is a set of n-tuples (a1, a2, …, an) where ai  Di Example: if student_number = set of 6 digit numbers student_name = {Jones, Smith, Curry, Lindsay} student_city = {Sydney, Brisbane, Melbourne, GoldCoast} Then r = { (100001, Jones, Brisbane), (100002, Curry, GoldCoast), (100003, Lindsay, Brisbane), (100004, Smith, Sydney)} is a relation over student_number x student_name x student_city Database Design lecture 2 7

Properties of Relations No duplicate tuples within a relation By definition sets do not contain duplicate elements, hence no tuples should appear more than once. Ordering of tuples has no significance elements in a set has no ordering also in the sense that no information is lost or added when different orders are used. but it may affect performance! Ordering of attributes has no significance in the sense that no information is lost or added if the attributes are ordered differently. BUT it is important when a tuple is considered an ordered list - for easy presentation. Alternative definition of tuple can make the ordering unimportant – a tuple is a mapping from attributes to values. Database Design lecture 2 8

In each tuple of R, values of K uniquely identify that tuple. Relational Keys Superkey An attribute, or a set of attributes, that can uniquely identify a tuple within a relation. Every relation has at least one superkey -- all attributes of the relation Key (Candidate Key) Superkey (K) such that no proper subset is a superkey within the relation. In each tuple of R, values of K uniquely identify that tuple. Removing any attribute from K, K will no longer be a superkey. Database Design lecture 2 9

Candidate keys that are not selected to be primary key. Relational Keys Primary Key (PK) Candidate key selected to identify tuples uniquely within relation. PK attributes will be underlined. Alternate Keys Candidate keys that are not selected to be primary key. Foreign Key (FK) Attribute, or set of attributes, within one relation that matches candidate key of some (possibly same) relation. Database Design lecture 2 10

Subjects(subjNo, subjName, points) Students(studNo, Name, Addr, Phone) Foreign Keys Example Subjects(subjNo, subjName, points) Students(studNo, Name, Addr, Phone) Enrollment(studNo, subjNo, semester, grade) In enrollment, studNo is a FK which references Students subjNo is a FK which references Subjects Database Design lecture 2 11

Another Example of FKs Database Design lecture 2 12

Relational Constraints Domain constraints Specify the possible values an attribute can take Null-value constraints Specify whether Null value is allowed in an attribute Key constraints PK, AK Entity integrity No PK value can be NULL Referential integrity FK values must either be NULL or appear in corresponding attribute(s) of referenced relation. Data dependencies, Enterprise rules (later) Database Design lecture 2 13

Example Database Design lecture 2 14

Diagram Representation of FKs Database Design lecture 2 15

Alternative Schema Diagram Department Dept_locations DNAME DNUMBER MGRSSN MGRSTARTDATE Project DNUMBER DLOCATION PNAME PNUMBER PLOCATION DNUM Employee Dependent FNAME MINT LNAME SSN BDATE ADDRESS SEX SALARY SUPERSSN DNO ESSN DEPDENT_NAME SEX BDATE RELATIONSHIP Works_on ESSN PNO HOURS Database Design lecture 2 16