Database Systems: Design, Implementation, and Management Ninth Edition

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.
The Relational Database Model
ITS232 Introduction To Database Management Systems
The Relational Database Model
Chapter 2 The Relational Database Model
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 3 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.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 4-1.
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
LECTURE 3 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.
Relational Database: RDB Concepts
3 & 4 1 Chapters 3 and 4 Drawing ERDs October 16, 2006 Week 3.
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.
The Relational Database Model
Relational Database Model
DESIGNING DATABASE APPLICATIONS
Tables and Their Characteristics
Database Systems: Design, Implementation, and Management Tenth Edition
Chapter 4 Relational Model Characteristics
CIS 207 The Relational Database Model
Lecture 2 The Relational Model
Chapter 4 Relational Databases
THE RELATIONAL DATABASE MODEL
Databases and Information Management
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
DATABASE SYSTEM.
Relational Database Model
Databases and Information Management
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
Relational data model. Codd's Rule E.F Codd was a Computer Scientist who invented Relational model for Database management. Based on relational model,
Presentation transcript:

Database Systems: Design, Implementation, and Management Ninth Edition Chapter 4 The Relational Model Charactristics

Objectives In this chapter, students will learn: That the relational database model offers a logical view of data About the relational model’s basic component: relations That relations are logical constructs composed of rows (tuples) and columns (attributes) That relations are implemented as tables in a relational DBMS Database Systems, 9th Edition

Objectives (cont’d.) 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 Database Systems, 9th Edition

A Logical View of Data Relational model Table View data logically rather than physically Table Structural and data independence Resembles a file conceptually Relational database model is easier to understand than hierarchical and network models Database Systems, 9th Edition

Tables and Their Characteristics Logical view of relational database is based on relation Relation thought of as a table Table: two-dimensional structure composed of rows and columns Persistent representation of logical relation Contains group of related entity occurrences (entity set) Database Systems, 9th Edition

Database Systems, 9th Edition

Database Systems, 9th Edition

Keys Each row in a table must be uniquely identifiable Key is one or more attributes that determine other attributes Key’s role is based on determination If you know the value of attribute A, you can determine the value of attribute B Functional dependence Attribute B is functionally dependent on A if each value in column A determines one and only one value in column B Database Systems, 9th Edition

Database Systems, 9th Edition

Keys (cont’d.) Composite key Key attribute Candidate key Any determinant Composed of more than one attribute Key attribute Any attribute that is part of a key Candidate key Any determinant that determines ALL other attributes in the relation ( table ) Database Systems, 9th Edition

Keys (cont’d.) Nulls No data entry at all .It does not mean zero or space Not permitted in primary key to maintain entity integrity Should be avoided in other attributes If they are used improperly they Can represent: An unknown attribute value A known, but missing, attribute value A “not applicable” condition Database Systems, 9th Edition

Keys (cont’d.) Nulls (cont’d.) Can create problems when functions such as COUNT, AVERAGE, and SUM are used Can create logical problems when relational tables are linked Database Systems, 9th Edition

Keys (cont’d.) Controlled redundancy makes the relational database work Tables within the database share common attributes that enables them to be linked together Multiple occurrences of values not redundant when required to make the relationship work Redundancy exists only when there is unnecessary duplication of attribute values Database Systems, 9th Edition

Database Systems, 9th Edition

Keys (cont’d.) Foreign key (FK) Secondary key An attribute whose values match primary key values in the related table Secondary key Key used strictly for data retrieval purposes Database Systems, 9th Edition

Database Systems, 9th Edition

Integrity Rules Many RDBMs enforce integrity rules automatically but t is much safer to ensure that application design conforms to integrity rules We have 2 integrity rules : Entity integrity : ALL primary key values must be unique and does not contain null values 2) Referential integrity: FK values should refer to an existing valid tuple ( raw ) in another relation ( table ) Database Systems, 9th Edition

Database Systems, 9th Edition

Database Systems, 9th Edition

Designers use flags to avoid nulls Flags indicate absence of some value Database Systems, 9th Edition

Relational Set Operators Relational algebra Defines theoretical way of manipulating table contents using relational operators Closure :the use of relational algebra operators on existing relations produces new relations: SELECT DIFFERENCE PROJECT JOIN UNION PRODUCT INTERSECT DIVIDE Database Systems, 9th Edition

Database Systems, 9th Edition

Database Systems, 9th Edition

Database Systems, 9th Edition

Give an example of using UNION /INTERSECT/ DIFFERENCE Database Systems, 9th Edition

Relational Set Operators (cont’d.) Natural Join Links tables by selecting rows with common values in common attribute(s) Equijoin Links tables on the basis of an equality condition that compares specified columns Theta join Any other comparison operator is used Outer join Matched pairs are retained, and any unmatched values in other table are left null Database Systems, 9th Edition

Database Systems, 9th Edition

Database Systems, 9th Edition

Database Systems, 9th Edition

Database Systems, 9th Edition

Who is using Room # 410 and 411 together this semester? TEACHER 411 Malak Anwar 410 Amal Masheal ROOM # 410 411 TEACHER Malak Database Systems, 9th Edition

The Data Dictionary and System Catalog Provides detailed description 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 Is a system-created database whose tables store the user/designer-created database characteristics and contents. therefore, the system catalog tables can be queried just like any user/designer-created table Automatically produces database documentation which allows the RDBMS to check for and eliminate homonyms & synonyms

Database Systems, 9th Edition

Relationships within the Relational Database 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 Database Systems, 9th Edition

Relationships within the Relational Database (cont’d.) M:N relationships Cannot be implemented as such in the relational model M:N relationships can be changed into two1:M relationships Database Systems, 9th Edition

The 1:M Relationship Relational database norm Found in any database environment Database Systems, 9th Edition

Another EX: page 77 / 123 Each course can generate many classes Each class refers to only one course Database Systems, 9th Edition

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 Database Systems, 9th Edition

Optional Look at the figure 3.23 /Page 79 /125 Another relationship: department employs professor Database Systems, 9th Edition

The M:N Relationship M:N relationship is not supported directly in the relational model Can be implemented by creating a new entity (composite entity/bridge entity/associative entity) ---linking table witch include the primary keys of the tables that are to be linked Database Systems, 9th Edition

Look at figure 3.2 page 81 Database Systems, 9th Edition

Or you can create new primary key as ENROLL_LINE What is the appropriate data type for this key? Database Systems, 9th Edition

Database Systems, 9th Edition

Database Systems, 9th Edition

Database Systems, 9th Edition

Data Redundancy Revisited Data redundancy leads to data anomalies Can destroy the effectiveness of the database Foreign keys Control data redundancies by using common attributes shared by tables minimize data redundancies Sometimes, data redundancy is necessary Look at figure 3.30 /page 85 Database Systems, 9th Edition

Information requirements Design elegance Processing speed Database Systems, 9th Edition

Indexes Orderly arrangement to logically access rows in a table Is composed of an index key & set of pointers 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 A table can have many indexes, but each index is associated with only one table Database Systems, 9th Edition

Database Systems, 9th Edition

Codd’s Relational Database Rules In 1985, Codd published a list of 12 rules to define a relational database system Products marketed as “relational” that did not meet minimum relational standards Even dominant database vendors do not fully support all 12 rules Database Systems, 9th Edition

Summary Tables are basic building blocks of a relational database Keys are central to the use of relational tables Keys define functional dependencies Superkey Candidate key Primary key Secondary key Foreign key Database Systems, 9th Edition

Summary (cont’d.) Each table row must have a primary key that uniquely identifies all attributes Tables are linked by common attributes The relational model supports relational algebra functions SELECT, PROJECT, JOIN, INTERSECT UNION, DIFFERENCE, PRODUCT, DIVIDE Good design begins by identifying entities, attributes, and relationships 1:1, 1:M, M:N Database Systems, 9th Edition

Q8 ,9,10 Natural JOIN Database Systems, 9th Edition STU_CODE PROF_CODE DEPT_CODE 128569 2 6 512272 4 531235 553427 1 STU_CODE PROF_CODE DEPT_CODE 128569 2 6 512272 4 531235 553427 1 Database Systems, 9th Edition

Q11,12,13,14 Database Systems, 9th Edition BOOTH_PRODUCT BOOTH_PRICE Chips 1.5 Cola 1.25 Energy Drink 2 Chocolate Bar 1 BOOTH_PRODUCT BOOTH_PRICE Energy Drink 2 MACHINE_PRODUCT MACHINE_PRICE Chips 1.25 Chocolate Bar 1 Database Systems, 9th Edition