0% found this document useful (0 votes)
43 views22 pages

BCS-15 Relational Model I

BCS-15 Relational Model I

Uploaded by

Viswash
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views22 pages

BCS-15 Relational Model I

BCS-15 Relational Model I

Uploaded by

Viswash
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 22

Chapter 3

The Relational Model


Transparencies

© Pearson Education Limited 1995, 2005


Relational Model Terminology
 A relation is a table with columns and rows.
– Only applies to logical structure of the
database, not the physical structure.

 Attribute is a named column of a relation.

 Domain is the set of allowable values for one or


more attributes.

2
© Pearson Education Limited 1995, 2005
Relational Model Terminology
 Tuple is a row of a relation.

 Degree is the number of attributes in a relation.

 Cardinality is the number of tuples in a relation.

 Relational Database is a collection of normalized


relations with distinct relation names.

3
© Pearson Education Limited 1995, 2005
Alternative Terminology for Relational Model

4
© Pearson Education Limited 1995, 2005
Mathematical Definition of Relation
 Consider two sets, D1 & D2, where D1 = {2, 4} and D2
= {1, 3, 5}.
 Cartesian product, D1  D2, is set of all ordered
pairs, where first element is member of D1 and
second element is member of D2.

D1 D2 = {(2, 1), (2, 3), (2, 5), (4, 1), (4, 3), (4, 5)}

 Alternative way is to find all combinations of


elements with first from D1 and second from D2.
5
© Pearson Education Limited 1995, 2005
Database Relations
 Relation schema
– Named relation defined by a set of attribute
and domain name pairs.

 Relational database schema


– Set of relation schemas, each with a distinct
name.

6
© Pearson Education Limited 1995, 2005
Relational Keys
Key plays an important role in relational database .It
is used for identifying unique rows from table. It also
establishes relationship among tables.
Superkey
Candidate Keys
Primary Key
Alternate Keys
Foreign Key
Composite Key

7
SuperKey
 Superkey
– An attribute, or set of attributes, that uniquely
identifies a tuple within a relation.

8
© Pearson Education Limited 1995, 2005
Table: Employee

Emp_SSN Emp_Number Emp_Name

11 116 Anshika
12 117 Devanshi
15 118 Aditya
16 119 Arun

All of the following sets of super key are able to uniquely identify a row of
the employee table.
•{Emp_SSN}
•{Emp_Number}
•{Emp_SSN, Emp_Number}
•{Emp_SSN, Emp_Name}
•{Emp_SSN, Emp_Number, Emp_Name}
9

•{Emp_Number, Emp_Name}
Candidate Key

 Candidate Key
– Superkey (K) such that no proper subset is a superkey
within the relation.
– In each tuple of R, values of K uniquely identify that
tuple (uniqueness).
– No proper subset of K has the uniqueness property
(irreducibility).

10
Table: Employee

Emp_SSN Emp_Number Emp_Name

11 116 Anshika
12 117 Devanshi
15 118 Aditya
16 119 Arun

11
Primary Key

Primary Key
– Candidate key selected to identify tuples uniquely within
relation.

We denote it by underlining the attribute name (column name).

The value of primary key should be unique for each row of the
table. The column(s) that makes the key cannot contain duplicate
values.

The attribute(s) that is marked as primary key is not allowed to


have null values.

12
Table : STUDENT
Stu_Id Stu_Name Stud_Age

11 Deepak 20
12 Kavya 19
15 Mohit 22
16 Aman 23

13
Alternate Keys

Alternate Keys
– Candidate keys that are not selected to be primary
key.

14
Table: Employee
Emp_Id Emp_Number Emp_Name

11 116 Namita
12 117 Anju
15 118 Vaibhav
16 119 Prakhar

15
Foreign Key

Foreign Key
– Attribute, or set of attributes, within one relation that
matches candidate key of some (possibly same) relation.

16
Table :Course_enrolment Table: Student

 Course_Id Stu_Id   Stu_Id Stu_Name Stu_Age

BCS-13 101
101 Rupal 22
BCS-14 102
102 Shreya 26
BCS-15 101
BCS-16 102 103 Harshit 25
BCS-17 103 104 Shivam 21
BCS-18 102

17
Composite key
Any key such as super key, primary key, candidate key etc. can be called
composite key if it has more than one attributes.

18
Table :Sales

Cust_Id Order_Id Product_code Product_count


C01 0001 P007 20
C02 0002 P007 21
C02 0002 P130 92
C01 0001 P290 33

19
Integrity Constraints
 Null
– Represents value for an attribute that is
currently unknown or not applicable for tuple.
– Deals with incomplete or exceptional data.
– Represents the absence of a value and is not the
same as zero or spaces, which are values.

20
© Pearson Education Limited 1995, 2005
Integrity Constraints
 Entity Integrity
– In a base relation, no attribute of a primary
key can be null.

 Referential Integrity
– If foreign key exists in a relation, either
foreign key value must match a candidate
key value of some tuple in its home relation
or foreign key value must be wholly null.

21
© Pearson Education Limited 1995, 2005
Integrity Constraints
 General Constraints
– Additional rules specified by users or
database administrators that define or
constrain some aspect of the enterprise.

22
© Pearson Education Limited 1995, 2005

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy