Download presentation
Presentation is loading. Please wait.
Published byDwayne Bond Modified over 9 years ago
1
1 Mathematical Relation A mathematical relation is a subset of a Cartesian Product. A1 A2 A3 … An = {(x1, x2, x3, …, xn): xi Ai} R A1 A2 A3 … An
2
2 Mapping and Relation R1 = {(1, 2), (1, 5), (2, 5)} = {(x, y) | x is in A, y is in B, x < y and x <= 2} A relationship between A and B 12341234 2525
3
3 How Many Possible Relations/Mappings between A and B A = {1, 2, 3, 4} B = {2, 5} R A B
4
4 Functions Function is a mapping, but not one-to-one! y = f(x) For the same value of x, the value of y always the same. y1 = f(3) u = 2 y2 = f(u + 1) Both y1 and y2 have the same value! It’s NOT one-to-many!
5
5 Functions (II) But for different values of x, the value of y could be the same. y = f(x) = x 2 f(2) = f(-2) It could be many-to-one.
6
6 Functions (III) Many-to-One Total / Partial (Total) X1 X2 X3 X4 A2 A4 A6 A8
7
7 Relation Example Student = {s: s is a student registered at UWP this semester} Course = {c: c is a course offered at UWP this semester}
8
8 Student Taking Course Student Course S9 S2 S4 S5 C1 C2 C3 C5 Partial or Total?
9
9 Student Taking Course Student Course S9 S2 S4 S5 C1 C2 C3 C5 Partial
10
10 Example S = {s | s is a student registered at UWP this semester} C = {c | c is a course offered at UWP this semester} S C: All possible registrations Registration = {(s, c): (s, c) S C and s is taking c} Partial for both S and C Many-to-many It can be updated!
11
11 Terminology R1 = {(1, 2), (1, 5), (2, 5)} R1 A B Tuple: (1, 2), (1, 5) and (2, 5) Cardinality: 3 Domain: A for the 1 st component B for the 2 nd component
12
12 Using Tables for Relations Att1Att2 Att3 15x 510w 42x 35y R = {(1, 5, x), (4, 2, x), (3, 5, y), (5, 10, w)}
13
13 Database Relations (Tables) Relation (Table) Attribute (Field, column) Tuple (Record, row) Domain for each field Degree (number of fields): 3 Cardinality (number of records): 4 Att1Att2 Att3 15x 510w 42x 35y
14
14 Table Instance A subset of the Cartesian Product No duplicates Update Tuples can be modified New tuples can be inserted Old tuples can be deleted Different instance after update Student Course S2C2 S3C2 S2C5
15
15 Relation Schema A named relation defined by a set of attribute and domain pairs. R (Att1:A1, Att2:A2, Att3:A3) R (Att1, Att2, Att3) Domain: Att1: A1 Att2: A2 Att3: A3 The relation schema represents the Cartesian Product A1 A2 A3 Same table schema, different table instances.
16
16 Relational Model What is a Relational Database? A collection of relations (tables) Relational Database: A collection of normalized relations (tables) with distinct relation/table names.
17
17 Database Schema Collection of Relation Schemas Database definition
18
18 Database Instance Relation instances (Tables) Actual records Store Data Update Data Retrieve Data
19
19 Properties of Relations Each relation has a distinct name (within the database) Each attribute has a distinct name (within the relation) Each tuple is distinct Each cell contains exactly one atomic (single) value The order of attributes has no significance The order of tuples has no significance
20
20 Database UWP Student(ID, Name, Phone, Address…) Course(ID, Title, Department, Credits…) Faculty(ID, Name, Department, Phone, Address…) Registration (Student, Course) Other possible fields? Schedule (Faculty, Course) Other possible fields? Other tables
21
Chapter 3 The Relational Model 3.2 Terminology 21
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.