Download presentation
Presentation is loading. Please wait.
Published byAbigayle Chapman Modified over 9 years ago
1
Announcements Reading for Monday –4.6 Homework 3 – Due 9/29
2
The Relational Model Lecture 7
3
Advantages of Relational Model Based on mathematical notion of relation Can use power of mathematical abstraction Can develop body of results using theorem and proof method of mathematics – results then apply to many different applications Can use expressive, exact mathematical notation Theory provides tools for improving design Basic structure is simple, easy to understand Separates logical from physical level Data operations easy to express, using a few powerful commands Operations do not require user to know storage structures used
4
Data Structures Relations are represented physically as tables Table Rows Column Domains
5
Properties of Tables Each cell Each column Values in a column all come from the same domain Each tuple Order of tuples is immaterial
6
Example of Relational Model Student table tells facts about students Faculty table shows facts about faculty Class table shows facts about classes, including what faculty member teaches each Enroll table relates students to classes
7
Mathematical Relations Cartesian product Let D 1 = { +, - } Let D 2 = {1,2,3} Calculate the Cartesian product
8
Mathematical Relations Relation Example
9
Describing Relations Give rules for selection of the tuples that will be part of the relation
10
Three sets Could form Cartesian product of 3 sets; relation is any subset of the ordered triples so formed A relation where the third element is the sum of the first two
11
n-tuples Could extend to n sets
12
Database Relations Relation schema, R, Relation, r,
13
Database Relations r is a set of n-tuples (A 1 :d 1, A 2 :d 2, …, A n :d n ) such that d 1 є D 1, d 2 є D 2, …, d n є D n
14
Database Relations In a table to represent the relation, list the A i as column headings, and let the (d 1, d 2, …d n ) become the n-tuples, the rows of the table
15
Properties of Relations Degree: – Cardinality: – Keys Integrity constraints
16
Relation Keys Superkey: Candidate key:
17
Relation Keys Primary key: Cannot verify a key by looking at an instance; need to consider semantic information to ensure uniqueness Foreign key
18
Integrity Constraints Integrity:
19
Types of constraints Domain constraint: Entity integrity: Referential integrity: General constraints or business rules:
20
Representing Relational Database Schemas Can have any number of relation schemas For each relation schema list name of relation followed by list of attributes in parentheses Underline primary key in each relation schema Indicate foreign keys (We use italics – arrows are best) Database schema actually includes domains, views, character sets, constraints, stored procedures, authorizations, etc.
21
University database schema Student (stuId, lastName, firstName, major, credits) Class (classNumber, facId, schedule, room) Faculty (facId, name, department, rank) Enroll(stuId,classNumber,grade)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.