Lecture 2 The Relational 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.
The Relational Database Model
ITS232 Introduction To Database Management Systems
Chapter 3 The Relational Model Transparencies © Pearson Education Limited 1995, 2005.
The Relational Database Model
Chapter 2 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.
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
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.
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.
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 –
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.
Logical Database Design and the Rational Model
The Relational Database Model
Tables and Their Characteristics
Database Systems: Design, Implementation, and Management Tenth Edition
Chapter 4 Relational Model Characteristics
CIS 207 The Relational Database 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.
The 1:M Relationship (continued)
part 1 with pages 1-32 and part 2 with pages 33-69
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 4 The Relational Model Pearson Education © 2009.
Database Systems: Design, Implementation, and Management Ninth Edition
The Relational Model Transparencies
Chapter 4 The Relational Model Pearson Education © 2009.
DATABASE SYSTEM.
Chapter 4 The Relational Model Pearson Education © 2009.
The Relational Database Model
Chapter # 3 The Relational Database Model.
DCT 2053 DATABASE CONCEPT Chapter 2.2 CONTINUE
Chapter 4 The Relational Model Pearson Education © 2009.
Database Systems: Design, Implementation, and Management
Relational Database Operators
Presentation transcript:

Lecture 2 The Relational Model Updated 19/9/2016 21/3/2014 TMC2034 Database Concept and Design

TMC2034 Database Concept and Design Objectives In this chapter, students will learn about the fundamental of a relational model Domains Relations Attributes Relationships Keys Integrity Rules Relational operations Data Dictionary Indexes 21/3/2014 TMC2034 Database Concept and Design

TMC2034 Database Concept and Design 21/3/2014 TMC2034 Database Concept and Design

TMC2034 Database Concept and Design Data Models Model is a collection of tools: diagrams and a set of vocabularies A data model provides description of the database structure: data, relationships, constraints, operations and meanings Examples: entity relationship model, object- oriented model, object-relational model and large- scale data models 21/3/2014 TMC2034 Database Concept and Design

TMC2034 Database Concept and Design A Relational Model By far the most widely used model for database design Built on the algebra Consist of a collection of relations View data logically rather than physically 21/3/2014 TMC2034 Database Concept and Design

TMC2034 Database Concept and Design Domains A set of scalar values from which attribute values are drawn. Scalar values are non-decomposable (atomic) values. Values permitted for each attribute Domains are conceptual, not store in database Domains subset containing actual attributes are stored Domains are analogous to data types in programming languages in C++, Java etc 21/3/2014 TMC2034 Database Concept and Design

TMC2034 Database Concept and Design 21/3/2014 TMC2034 Database Concept and Design

TMC2034 Database Concept and Design Relations (1) Logical view of relational database is based on relation Relation thought of as a table (also entity) Table: two-dimensional structure composed of rows and columns Persistent representation of logical relation Contains group of related entities (relation also known as entity set) Examples: Students, Courses … 21/3/2014 TMC2034 Database Concept and Design

TMC2034 Database Concept and Design Relations (2) TMC2034 Database Concept and Design

TMC2034 Database Concept and Design

TMC2034 Database Concept and Design Relations (3) Various types of relations Base relations View (virtual relations) Snapshots (read-only) Query results A query always results in a new relations Temporary relations Destroyed at some point in time TMC2034 Database Concept and Design

TMC2034 Database Concept and Design Attributes (1) A very important relation properties An attribute has different permitted values from a domain Examples: Student Id, course name … How to determine if an object (entity) is a relation or an attributes? 21/3/2014 TMC2034 Database Concept and Design

TMC2034 Database Concept and Design Attributes (2) Null Values Absence of any data value that could represent: An unknown attribute value A known, but missing, attribute value A inapplicable condition Causes Can create problems when functions such as COUNT, AVERAGE, and SUM are used Can create logical problems when relational tables are linked 21/3/2014 TMC2034 Database Concept and Design

TMC2034 Database Concept and Design Keys (1) Consist of one or more attributes that determine other attributes Used to: Ensure that each row in a table is uniquely identifiable Establish relationships among tables and to ensure the integrity of the data Primary key (PK): Attribute or combination of attributes that uniquely identifies any given row 21/3/2014 TMC2034 Database Concept and Design

TMC2034 Database Concept and Design Keys (2) Determination State in which knowing the value of one attribute makes it possible to determine the value of another Is the basis for establishing the role of a key Based on the relationships among the attributes 21/3/2014 TMC2034 Database Concept and Design

TMC2034 Database Concept and Design Keys (3) TMC2034 Database Concept and Design

TMC2034 Database Concept and Design

TMC2034 Database Concept and Design Quiz 1 A _____ key is any key that uniquely identifies each row A. super B. special C. selective D. candidate 21/3/2014 TMC2034 Database Concept and Design

TMC2034 Database Concept and Design Relationships (1) 1:M relationship Relational modeling ideal Should be the norm in any relational database design 1:1 relationship Should be rare in any relational database design 21/3/2014 TMC2034 Database Concept and Design

TMC2034 Database Concept and Design Relationships (2) M:N relationships Cannot be implemented as such in the relational model M:N relationships can be changed into 1:M relationships 21/3/2014 TMC2034 Database Concept and Design

TMC2034 Database Concept and Design The 1:M Relationship Relational database norm Found in any database environment 21/3/2014 TMC2034 Database Concept and Design

TMC2034 Database Concept and Design

TMC2034 Database Concept and Design The 1:1 Relationship One entity related to only one other entity, and vice versa Sometimes means that entity components were not defined properly Could indicate that two entities actually belong in the same table Certain conditions absolutely require their use 21/3/2014 TMC2034 Database Concept and Design

TMC2034 Database Concept and Design

TMC2034 Database Concept and Design The M:N Relationship Implemented by breaking it up to produce a set of 1:M relationships Avoid problems inherent to M:N relationship by creating a composite entity Includes as foreign keys the primary keys of tables to be linked 21/3/2014 TMC2034 Database Concept and Design

TMC2034 Database Concept and Design

TMC2034 Database Concept and Design

TMC2034 Database Concept and Design 21/3/2014 TMC2034 Database Concept and Design

TMC2034 Database Concept and Design 21/3/2014 TMC2034 Database Concept and Design

TMC2034 Database Concept and Design 21/3/2014 TMC2034 Database Concept and Design

TMC2034 Database Concept and Design Integrity Rules Many RDBMs enforce integrity rules automatically Safer to ensure that application design conforms to entity and referential integrity rules Null value breaks integrity Designers use flags to avoid nulls Flags indicate absence of some value 21/3/2014 TMC2034 Database Concept and Design

Integrity Rules – Entity Integrity Description Requirement All primary key entries are unique, and no part of a primary key may be null Purpose Each row will have a unique identity, and foreign key values can properly reference primary key values Example No invoice can have a duplicate number, nor it can be null 21/3/2014 TMC2034 Database Concept and Design

Integrity Rules - Referential Integrity Entity Integrity Description Requirement A foreign key may have either a null entry or a entry that matches a primary key value in a table to which it is related Purpose It is possible for an attribute not to have a corresponding value but it is impossible to have an invalid entry It is impossible to delete row in a table whose primary keys has mandatory matching foreign key values in another table Example It is impossible to have invalid sales representative number 21/3/2014 TMC2034 Database Concept and Design

TMC2034 Database Concept and Design

TMC2034 Database Concept and Design Quiz 2 Referential ____ means if the foreign key contains a value, that value refers to an existing valid tuple (row) in another relation. A. integrity B. uniqueness C. direction D. relations 21/3/2014 TMC2034 Database Concept and Design

TMC2034 Database Concept and Design Relational Algebra Defines the theoretical way of manipulating table contents using relational operators Relvar: Variable that holds a relation Heading contains the names of the attributes and the body contains the relation Relational operators have the property of closure Closure: Use of relational algebra operators on existing relations produces new relations 21/3/2014 TMC2034 Database Concept and Design

Relational Set Operators (1) Relational algebra SELECT UNION PROJECT DIFFERENCE JOIN PRODUCT INTERSECT DIVIDE 21/3/2014 TMC2034 Database Concept and Design

Relational Set Operators (2) Unary operator that yields a horizontal subset of a table Select (Restrict) Unary operator that yields a vertical subset of a table Project Combines all rows from two tables, excluding duplicate rows Union-compatible: Tables share the same number of columns, and their corresponding columns share compatible domains Union Yields only the rows that appear in both tables Tables must be union-compatible to yield valid results Intersect 21/3/2014 TMC2034 Database Concept and Design

TMC2034 Database Concept and Design Select TMC2034 Database Concept and Design

TMC2034 Database Concept and Design Project TMC2034 Database Concept and Design

TMC2034 Database Concept and Design Union TMC2034 Database Concept and Design

TMC2034 Database Concept and Design Intersect 21/3/2014 TMC2034 Database Concept and Design

Relational Set Operators (3) Difference Yields all rows in one table that are not found in the other table Tables must be union-compatible to yield valid results Product Yields all possible pairs of rows from two tables 21/3/2014 TMC2034 Database Concept and Design

TMC2034 Database Concept and Design Difference 21/3/2014 TMC2034 Database Concept and Design

TMC2034 Database Concept and Design Product 21/3/2014 TMC2034 Database Concept and Design

Relational Set Operators (4) Join Allows information to be intelligently combined from two or more tables Divide Uses one 2-column table as the dividend and one single- column table as the divisor Output is a single column that contains all values from the second column of the dividend that are associated with every row in the divisor 21/3/2014 TMC2034 Database Concept and Design

TMC2034 Database Concept and Design 21/3/2014 TMC2034 Database Concept and Design

TMC2034 Database Concept and Design Types of Joins Natural join Links tables by selecting rows with common values in common attributes (join columns) Equijoin Links tables on the basis of an equality condition that compares specified columns Theta join Any other comparison operator is used 21/3/2014 TMC2034 Database Concept and Design

Relational Set Operators (5) Inner join Only returns matched records from the tables that are being joined Outer join Matched pairs are retained, and any unmatched values in other table are left null Left outer join Right outer join 21/3/2014 TMC2034 Database Concept and Design

TMC2034 Database Concept and Design Quiz 3 To be considered minimally relational, the DBMS must support the key relational operators ____, PROJECT, and JOIN. A. INTERSECT B. UNION C. DIFFERENCE D. SELECT 21/3/2014 TMC2034 Database Concept and Design

The Data Dictionary and System Catalog Provides detailed accounting of all tables found within the user/designer-created database Contains (at least) all the attribute names and characteristics for each table in the system Contains metadata: data about data System catalog Contains metadata Detailed system data dictionary that describes all objects within the database 21/3/2014 TMC2034 Database Concept and Design

TMC2034 Database Concept and Design

The Data Dictionary and System Catalog (cont’d.) Homonym Indicates the use of the same name to label different attributes C_Name for Car and Customer name Synonym Opposite of a homonym Indicates the use of different names to describe the same attribute CUSTOMER vs C_Name 21/3/2014 TMC2034 Database Concept and Design

TMC2034 Database Concept and Design Indexes Orderly arrangement to logically access rows in a table Index key Index’s reference point Points to data location identified by the key Unique index Index in which the index key can have only one pointer value (row) associated with it Each index is associated with only one table 21/3/2014 TMC2034 Database Concept and Design

TMC2034 Database Concept and Design

TMC2034 Database Concept and Design Questions? 21/3/2014 TMC2034 Database Concept and Design