Chapter 2 The Relational Model. 2-2 In This Chapter You Will Learn   What a data model is and what its uses are   The terminology of the relational.

Slides:



Advertisements
Similar presentations
The Relational Model and Relational Algebra Nothing is so practical as a good theory Kurt Lewin, 1945.
Advertisements

RELATIONAL DATABASES. Relational data Structure RELATION: Table with columns and rows ATTRIBUTE: Column of a relation DOMAIN: Set of allowable values.
Chapter 3 : Relational Model
Relational Model (CB Chapter 4) CPSC 356 Database Ellen Walker Hiram College.
The Relational Model System Development Life Cycle Normalisation
Chapter 3 The Relational Model Transparencies © Pearson Education Limited 1995, 2005.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 3 The Basic (Flat) Relational Model.
Fundamentals of Relational Database Yong Choi School of Business CSUB, Bakersfield.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 3 The Relational Database Model.
Chapter 3. 2 Chapter 3 - Objectives Terminology of relational model. Terminology of relational model. How tables are used to represent data. How tables.
1 Minggu 2, Pertemuan 3 The Relational Model Matakuliah: T0206-Sistem Basisdata Tahun: 2005 Versi: 1.0/0.0.
© Pearson Education Limited, Chapter 3 SQL and QBE Transparencies.
1 Pertemuan 04 MODEL RELASIONAL Matakuliah: >/ > Tahun: > Versi: >
Thomas Connolly and Carolyn Begg’s
Relational Database Management System A type of database in which records are stored in relational form is called relational database management system.
LOGICAL DATABASE DESIGN
Database Architecture The Relational Database Model.
Chapter 3 Relational Model Chapter 4 in Textbook.
CSC271 Database Systems Lecture # 6. Summary: Previous Lecture  Relational model terminology  Mathematical relations  Database relations  Properties.
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.
Relational Model Session 6 Course Name: Database System Year : 2012.
1 The Relational Data Model, Relational Constraints, and The Relational Algebra.
Chapter 4 The Relational Model.
Chapter 3 The Relational Model Transparencies Last Updated: Pebruari 2011 By M. Arief
Entity-Relationship (ER) Data Model 概念資料模式 (Based on Chapter 3 in Fundamentals of Database Systems by Elmasri and Navathe, Ed. 4)
Chapter 6 Normalization 正規化. 6-2 In This Chapter You Will Learn:  更動異常  How tables that contain redundant data can suffer from update anomalies ( 更動異常.
CG084&085 / / 1 The Relational Data Model Properties of Relations Keys and Constraints.
Fundamentals of Relational Database Yong Choi School of Business CSUB, Bakersfield.
Module 3: The Relational Model.  Overview Terminology Relational Data Structure Mathematical Relations Database Relations Relational Keys Relational.
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.
1 The Relational Database Model. 2 Learning Objectives Terminology of relational model. How tables are used to represent data. Connection between mathematical.
© Pearson Education Limited, Chapter 9 Logical database design – Step 1 Transparencies.
9/7/2012ISC329 Isabelle Bichindaritz1 The Relational Database Model.
The Relational Model Pertemuan 03 Matakuliah: M0564 /Pengantar Sistem Basis Data Tahun : 2008.
Relational Database. Database Management System (DBMS)
Slide Chapter 5 The Relational Data Model and Relational Database Constraints.
The University of Akron Dept of Business Technology Computer Information Systems The Relational Model: Concepts 2440: 180 Database Concepts Instructor:
Chapter 9 Logical Database Design : Mapping ER Model To Tables.
12/2/2015CPSC , CPSC , Lecture 41 Relational Model.
L8-2-S1 Misc Topics © M.E. Fayad SJSU -- CmpE Database Design Dr. M.E. Fayad, Professor Computer Engineering Department, Room #283I College of.
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 A data model (in general) : Integrated collection of concepts for describing data (data requirements). Relational model was introduced.
Chapter 8 Conceptual Data Modeling (概念性的資料建模)
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,
CHAPTER 2 : RELATIONAL DATA MODEL Prepared by : nbs.
The Relational Model © Pearson Education Limited 1995, 2005 Bayu Adhi Tama, M.T.I.
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.
CSCI 6315 Applied Database Systems Review for Midterm Exam I Xiang Lian The University of Texas Rio Grande Valley Edinburg, TX 78539
Chapter 3 The Relational Model. Objectives u Terminology of relational model. u How tables are used to represent data. u Connection between mathematical.
INFORMATION TECHNOLOGY DATABASE MANAGEMENT. A database is a collection of information organized to provide efficient retrieval. The collected information.
Chapter 4 The Relational Model Pearson Education © 2009.
LECTURE TWO Introduction to Databases: Data models Relational database concepts Introduction to DDL & DML.
IT 5433 LM3 Relational Data Model. Learning Objectives: List the 5 properties of relations List the properties of a candidate key, primary key and foreign.
The Relational Data Model and Relational Database Constraints
The Relational Database Model
© Pearson Education Limited, 2004
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 4+17 The Relational Model Pearson Education © 2014.
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.
Design tools and techniques for a relational database system
Chapter 4 The Relational Model Pearson Education © 2009.
INSTRUCTOR: MRS T.G. ZHOU
Chapter 3 The Relational Model
Presentation transcript:

Chapter 2 The Relational Model

2-2 In This Chapter You Will Learn   What a data model is and what its uses are   The terminology of the relational model   How tables are used to represent data   Properties of database tables   How to identify candidate, primary, and foreign keys   The meaning of entity integrity (實體完整限制式) and referential integrity (參照完整限制式)

2-3 What Is A Data Model?   An integrated collection of concepts for describing data, relationships between data, and constraints on the data.   A data model attempts to represent the operation of a company or part of the company, that you wish to model.   It provides the essential concepts and notations that allow database designers and end-users to communicate their understanding of the company unambiguously and accurately.

2-4 Three Components Of A Data Model   A Structure Part   How the database is to be constructed   A Manipulative Part   Types of data operations that are allowed   Updating or retrieving data   Changing the structure of the database   A Set Of Integrity Rules   Ensures that the data is accurate

2-5 Terminology of Relational Model   Relation (關聯、關係)   Table with columns and rows   Columns ~ Attributes   Rows ~ Individual records   We use tables to hold information about the objects that we want to represent in the database.   Attribute (屬性)   Named column of a table   Can appear in any order, and the table will still be the same

2-6   A case example : StayHome Video Rental Company   The information on branches ( 分店 ) is represented by the Branch relation, with columns for attributes branchNo, street, city, state, zipCode, and mgrStaffNo.   The information on staff is represented by the Staff relation, with columns for attributes staffNo, name, position, salary, and branchNo. Terminology of Relational Model

2-7 An example of the Branch and Staff relations

2-8   Domain (定義域)   A set of allowable (possible) values for one or more attributes   Every attribute in a relational database is associated with a domain   May be distinct for each attribute. Or, two or more attributes may be associated with the same domain Terminology of Relational Model

2-9 Domain Example (For Some Attributes of Branch Relation

2-10   Tuple (值組)   A record of a relation   In the Staff relation, each record contains five values, one for each attribute.   A Relational Database   A collection of normalized tables with distinct table names. Terminology of Relational Model

2-11 Seven Properties of Relational Tables 1. 1.Table name is distinct from all other table names in the database Each column has a distinct name in a table Each cell of a table contains exactly one value.   To store several telephone number for a single branch in a single cell is wrong (No repeating groups.)   A table satisfying this property is said to be normalized or in first normal ( 正規化 ) form.

2-12 Seven Properties of Relational Tables 4. 4.Values of a column are all from the same domain 5. 5.Each record is distinct.   There are no duplicate records Order of columns has no significance (To users and programmers) 7. 7.Order of records has no significance. (To users and programmers)

2-13 Relational Keys   Candidate key (候選鍵)   Primary key (主鍵)   Foreign key (外部鍵、外來鍵、外鍵)

2-14 Candidate Key (候選鍵)   A column, or a set of columns, that uniquely identifies a record within a table.   Uniqueness (唯一性) : In a table, the value of the candidate key uniquely identifies a record   Irreducibility (不可減少性,最小性 ) : No proper subset of the candidate key has the uniqueness property   The key cannot be made smaller or simpler for unique identification   There may be many candidate keys for a table   When a key consists of more than one column, we call it a composite key (組合鍵).

2-15 Candidate Key (候選鍵) Can city be a candidate key? Can zipCode be a candidate key? Can branchNo be a candidate key? Can mgrStaffNo be a candidate key? Branch relation

2-16 Candidate Key (候選鍵) Can actorNo be a candidate key? Role Table The characters played by actors in videos Can catalogNo be a candidate key? actorNocatalogNo? actorNo + catalogNo? actorNo+ character? actorNo + character?

2-17 Keys Primary Key (主鍵)  The candidate key selected to identify records uniquely for a given table.  A table always has a primary key.  The Worst Case: The entire set of columns serve as the primary key

2-18 Rules To Select Primary Key   With minimal number of attributes   Less likely to have its values changed (or never changed)   Less likely to lose uniqueness in the future   Always have values   With fewest characters (for those with textual attribute)   With the smallest maximum value (for numerical attribute)   Easiest to use from the users’ point of view

2-19 Foreign Key (外部鍵、外索引)   A column, or set of columns, within one table that matches the primary key of some (possibly same) table.   When a column appears in more than one table, its appearance represents a relationship between the records of the two tables

2-20 Relational Keys Parent/Home Table Primary Key Foreign Key Child Table

2-21 Functions of Keys 1.Who is the manager of the branch at Portland, OR ? 2.Who are the managers of the branch at Seattle, WA ? 3. Who is Sally Adams’s manager ?

2-22 Relational Keys of COMPANY Database (PK and FK)

2-23 Representing Relational Databases (The StayHome Database) Branch ( branchNo, street, city, state, zipCode, mgStaffNo) Staff ( staffNo, name, position, salary, branchNo) Video ( catalogNo, title, category, dailyRental, price, directorNo) Director ( directorNo, directorName) Actor ( actorNo, catalogNo) Role ( actorNo, catalogNo, character) Member ( memberNo, fName, lName, address) Registration ( branchNo, memberNo, staffNo, dateJoined) RentalAgreement ( rentalNo, dateOut, dateReturn, memberNo, videoNo) VideoForRent ( videoNo, available, catalogNo, branchNo) data example data example

2-24 Data example of StayHome DB (1)

2-25 Data example of StayHome DB (2)

2-26 Relational Integrity (關聯完整限制式、關聯的完整性)   Ensures that the data of a database is accurate   Constraints that apply to the entire database   Entity Integrity (實體完整限制式)   Referential Integrity (參照完整限制式)   Before defining these two constraints, let’s look at   Null ( 虛值)   Business Rules

2-27 Null (虛值、空值)   Represents a value for a column that is currently unknown or is not applicable ( 不適用 ) for a record.   Deals with incomplete or exceptional data.   Examples   A branch temporarily without a manager

2-28 Business Rules (企業規則)   Specify additional constraints that the data must satisfy.   Represented in the form of rules that define or constrain some operations of the organization.   Example   A member can only rent a maximum of 10 videos at any one time

2-29 Entity Integrity (實體完整限制式、實體的完整性)   Applies to the primary key of a base table.   In a base table, no column of a primary key can be null.   A base table is a named table whose records are physically stored in the database.   Note: A view is a ‘virtual table’ that does not actually exist in the database but is generated by the DBMS from some underlying base tables dynamically.

2-30 Referential Integrity (參照完整限制式、參照的完整性)   If foreign key exists in a table,   either the foreign key value of a record in the table must match a candidate key value of some record in its parent/home table,   or the foreign key value must be wholly null.   Example:   Not possible to create a staff record with branch number B300 (since B300 does not exist.)   Can create a new staff record with a null branch number if null value is allowed