The Relational Database Model

Slides:



Advertisements
Similar presentations
Relational Database Operators
Advertisements

The Relational Model and Relational Algebra Nothing is so practical as a good theory Kurt Lewin, 1945.
Relational Algebra, Join and QBE Yong Choi School of Business CSUB, Bakersfield.
Relational Databases - Amit Bhawnani & Nimesh Shah.
The Relational Database Model – some relations you might want to avoid!!!
The Relational Database Model
ITS232 Introduction To Database Management Systems
Chapter 2 The Relational Database Model
The Relational Database Model
Chapter 3 The Relational Database Model
The Relational Database Model. 2 Objectives How relational database model takes a logical view of data Understand how the relational model’s basic components.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 3 The Relational Database Model.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 3 The Relational Database Model.
3 1 Chapter 3 The Relational Database Model Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
The Relational Database Model
The Relational Database Model
3 The Relational Model MIS 304 Winter Class Objectives That the relational database model takes a logical view of data That the relational model’s.
The Relational Database Model
© Pearson Education Limited, Chapter 2 The Relational Model Transparencies.
Relational Model: Examples. Banking Example branch (branch_name, branch_city, assets) customer (customer_name, customer_street, customer_city) account.
Chapter 3 Section 3.4 Relational Database Operators
Database System Concepts, 5 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 2: Relational.
S511 Session 4, IU-SLIS 1 Relational Database Model.
1 The Relational Model By Elena Ciriani CS157A February 19, 2004 Professor Lee.
The Relational Database Model
1 The Relational Database Model. 2 Learning Objectives Terminology of relational model. How tables are used to represent data. Connection between mathematical.
9/7/2012ISC329 Isabelle Bichindaritz1 The Relational Database Model.
CS 370 Database Systems Lecture 11 Relational Algebra.
3 1 Chapter 3 The Relational Database Model Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
Module Coordinator Tan Szu Tak School of Information and Communication Technology, Politeknik Brunei Semester
ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail | Muhd Eizan Shafiq Abd Aziz Faculty of Computer & Mathematical Sciences, UiTM Kedah.
Relational Database: RDB Concepts
Database Systems, 9th Edition 1.  In this chapter, students will learn: That the relational database model offers a logical view of data About the relational.
3 1 Chapter 3 The Relational Database Model Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Database Systems: Design, Implementation, and Management Tenth Edition Chapter 3 The Relational Database Model.
Database Systems: Design, Implementation, and Management Ninth Edition Chapter 3 The Relational Database Model.
Chapter 3 The Relational Database Model. Logical View of Data Relational Database – Designer focuses on logical representation rather than physical –
2.1 Chapter 2: Relational Model. 2.2 Chapter 2: Relational Model Structure of Relational Databases Fundamental Relational-Algebra-Operations Additional.
©Silberschatz, Korth and Sudarshan3.1Database System Concepts Chapter 3: Relational Model Structure of Relational Databases Relational Algebra Extended.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 3 The Relational Database Model.
Department of Mathematics Computer and Information Science1 CS 351: Database Systems Christopher I. G. Lanclos Chapter 3: The Relational Database Model.
3 1 Database Systems The Relational Database Model.
3 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Relational Algebra Operators (continued) Difference –Yields all.
3 1 Chapter 3 The Relational Database Model Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 3 The Relational Database Model.
Chapter 3 The Relational Database Model. Database Systems, 10th Edition 2 * Relational model * View data logically rather than physically * Table * Structural.
CHAPTER 2 : RELATIONAL DATA MODEL Prepared by : nbs.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 3 The Relational Database Model.
Database Systems: Design, Implementation, and Management Tenth Edition Chapter 3 The Relational Database Model.
Week 2 Lecture The Relational Database Model Samuel ConnSamuel Conn, Faculty Suggestions for using the Lecture Slides.
The Relational Database Model
Relational Database Model
Database Systems: Design, Implementation, and Management Tenth Edition
Chapter 4 Relational Model Characteristics
CIS 207 The Relational Database Model
Lecture 2 The Relational Model
THE RELATIONAL DATABASE MODEL
Theory behind the relational engine
Theory behind the relational engine
The Relational Database Model
Chapter 3 The Relational Database Model
Chapter 3 The Relational Database Model.
Database Systems: Design, Implementation, and Management Ninth Edition
DATABASE SYSTEM.
The Relational Database Model
Chapter # 3 The Relational Database Model.
DCT 2053 DATABASE CONCEPT Chapter 2.2 CONTINUE
Database Systems: Design, Implementation, and Management
Relational Database Operators
Presentation transcript:

The Relational Database Model Chapter 2 The Relational Database Model

In this chapter, you will learn: That the relational database model takes a logical view of data That the relational database model’s basic components are entities and their attributes, and relationships among entities How entities and their attributes are organized into tables About relational database operators, the data dictionary, and the system catalog How data redundancy is handled in the relational database model Why indexing is important Hachim Haddouti and Rob & Coronel, Ch2

Hachim Haddouti and Rob & Coronel, Ch2 Logical View of Data Relational Database Designer focuses on logical representation rather than physical Use of table advantageous Structural and data independence Related records stored in independent tables Logical simplicity Allows for more effective design strategies Hachim Haddouti and Rob & Coronel, Ch2

Logical View of Data (con’t.) Entities and Attributes Entity is a person, place, event, or thing about which data is collected Attributes are characteristics of the entity Tables Holds related entities or entity set Also called relations Comprised of rows and columns Hachim Haddouti and Rob & Coronel, Ch2

Table Characteristics Two-dimensional structure with rows and columns Rows (tuples) represent single entity Columns represent attributes Row/column intersection represents single value Tables must have an attribute to uniquely identify each row Hachim Haddouti and Rob & Coronel, Ch2

Table Characteristics (con’t.) Column values all have same data format Each column has range of values called attribute domain Order of the rows and columns is immaterial to the DBMS Hachim Haddouti and Rob & Coronel, Ch2

Hachim Haddouti and Rob & Coronel, Ch2 Keys One or more attributes that determine other attributes Key attribute Composite key Functional dependence ( knowing STU_NUM you can determine STU_LNAME) Entity integrity Uniqueness No ‘null’ value in key ( NULL= 0?) Example: AUI ID#, Invoice#, CIN# Hachim Haddouti and Rob & Coronel, Ch2

Hachim Haddouti and Rob & Coronel, Ch2 Keys (con’t.) Superkey Uniquely identifies each entity in a table Candidate key Minimal superkey Primary key Candidate key to uniquely identify all other attributes in a given row Secondary key Used only for data retrieval Foreign key (logical pointer) Values must match primary key in another table Hachim Haddouti and Rob & Coronel, Ch2

Hachim Haddouti and Rob & Coronel, Ch2 Keys (con’t.) Hachim Haddouti and Rob & Coronel, Ch2

Hachim Haddouti and Rob & Coronel, Ch2 Integrity Rules Entity integrity Ensures all entities are unique Each entity has unique primary key (not null) Referential integrity Foreign key must have null value or match primary key values (every non-null FK must reference an existing primary key) Makes it impossible to delete row whose primary key has mandatory matching foreign key values in another table No dangling references ( Links in HTML?) Hachim Haddouti and Rob & Coronel, Ch2

Relational Database Operators Relational algebra determines table manipulations Basic operators SELECT PROJECT JOIN Other operators INTERSECT UNION DIFFERENCE PRODUCT Hachim Haddouti and Rob & Coronel, Ch2

Hachim Haddouti and Rob & Coronel, Ch2 Union Combines all rows Set-oriented union, duplicates will be eliminated (columns and domains must be identical), same Attribute characteristics Hachim Haddouti and Rob & Coronel, Ch2

Hachim Haddouti and Rob & Coronel, Ch2 Intersect Yields rows that appear in both tables Figure 2.6 Hachim Haddouti and Rob & Coronel, Ch2

Hachim Haddouti and Rob & Coronel, Ch2 Difference Yields rows not found in other tables Figure 2.7 Set-oriented difference columns and domains must be identical, same Attribute characteristics Hachim Haddouti and Rob & Coronel, Ch2

Product (Cartesian product) Yields all possible pairs from two tables Hachim Haddouti and Rob & Coronel, Ch2

Hachim Haddouti and Rob & Coronel, Ch2 Select Yields a subset of rows based on specified criterion Figure 2.9 Hachim Haddouti and Rob & Coronel, Ch2

Hachim Haddouti and Rob & Coronel, Ch2 Project Yields all values for selected attributes (vertical subset of a table) Hachim Haddouti and Rob & Coronel, Ch2

Hachim Haddouti and Rob & Coronel, Ch2 Join Information from two or more tables is combined by equal AGENT_CODE Hachim Haddouti and Rob & Coronel, Ch2

Hachim Haddouti and Rob & Coronel, Ch2 Natural Join Process Links tables by selecting rows with common values in common attribute(s) Three-stage process Product creates one table Select yields appropriate rows Project yields single copy of each attribute to eliminate duplicate columns Hachim Haddouti and Rob & Coronel, Ch2

Hachim Haddouti and Rob & Coronel, Ch2 Other Joins EquiJOIN Links tables based on equality condition that compares specified columns of tables Does not eliminate duplicate columns Join criteria must be explicitly defined Theta JOIN EquiJOIN that compares specified columns of each table using operator other than equality one Outer JOIN Matched pairs are retained Unmatched values in other tables left null Two types: right and left Hachim Haddouti and Rob & Coronel, Ch2

Data Dictionary and System Catalog Provides detailed account of all tables found within database Metadata Attribute names and characteristics System catalog Detailed data dictionary System-created database Stores database characteristics and contents Tables can be queried just like any other tables Automatically produces database documentation Hachim Haddouti and Rob & Coronel, Ch2

Hachim Haddouti and Rob & Coronel, Ch2 Indexes Points to location Makes retrieval of data faster Figure 2.31 Hachim Haddouti and Rob & Coronel, Ch2

Hachim Haddouti and Rob & Coronel, Ch2 Example 1 Identify and describe the components of the database table shown below using correct terminology. Hachim Haddouti and Rob & Coronel, Ch2

Hachim Haddouti and Rob & Coronel, Ch2 Example 1 cont. ·   1 entity set: EMPLOYEE. ·   5 attributes: EMP_NUM, EMP_LNAME, etc. ·  10 entities: the workers Friedman, Olansky, Fontein, and Cruazona. · one primary key: the attribute EMP_NUM because it identifies each row uniquely. two foreign keys: the attribute DEPT_CODE, which probably references a department to which the employee is assigned and the attribute JOB_CODE which probably references another table in which you would find the description of the job and perhaps additional information pertaining to the job. Hachim Haddouti and Rob & Coronel, Ch2

Hachim Haddouti and Rob & Coronel, Ch2 Example1 cont. Cutomer_no is superkey, (Customer_no, Customer_Name) is also superkey for the entity set CUSTOMER The combination of primary keys of the participating entity sets forms a super key of a relationship set. (customer-id, account-number) is the super key of depositor Concept of superkey is not sufficient PS: depositor (customer-name, account-number) Hachim Haddouti and Rob & Coronel, Ch2

Hachim Haddouti and Rob & Coronel, Ch2 Example 2: Banking branch (branch-name, branch-city, assets) customer (customer-name, customer-street, customer-only) account (account-number, branch-name, balance) loan (loan-number, branch-name, amount) depositor (customer-name, account-number) borrower (customer-name, loan-number) Stands for PROJECT,  for SELECT, &  for Union & INTERSECTION Hachim Haddouti and Rob & Coronel, Ch2

Example 2 Queries amount > 1200 (loan) Find all loans of over DH1200 amount > 1200 (loan) Find the loan number for each loan of an amount greater than DH1200 loan-number (amount > 1200 (loan)) Hachim Haddouti and Rob & Coronel, Ch2

Example 2 Queries Find the names of all customers who have a loan, an account, or both, from the bank customer-name (borrower)  customer-name (depositor) Find the names of all customers who have a loan and an account at bank. customer-name (borrower)  customer-name (depositor) Hachim Haddouti and Rob & Coronel, Ch2

Example 2 Queries Find the names of all customers who have a loan at the Ifrane branch of an amount greater than DH1200. customer-name ( amount > 1200 (borrower.loan-number = loan.loan-number(borrower x loan))) Find the names of all customers who have a loan at the branch IFRANE. customer-name (branch-name=“IFRANE” (borrower.loan-number = loan.loan-number(borrower x loan))) Hachim Haddouti and Rob & Coronel, Ch2