concept of a Relation.
management comes
foundation provided
relations.
Chapter 5-2
INFORMAL DEFINITIONS
RELATION: A table of values
Chapter 5-3
FORMAL DEFINITIONS
A Relation may be defined in multiple ways.
The Schema of a Relation: R (A1, A2, .....An)
Chapter 5-4
Example of a Relation
Data Structure
Data Integrity
Data Manipulation
Attribute:
Tuple
A tuple is an ordered set of values
Each value is derived from an appropriate domain.
Each row in the CUSTOMER table may be referred to as
Chapter 5-8
Example - Figure
5.1
Chapter 5-9
Domain
Is the set of allowed values for one or more
attributes.
Defines the kind of data represented by the attribute.
Example: If a college has 5000 students then the
domain of Roll number may be from 1001 to 6000.
Domain
Each attribute in the model should be assigned
Data type
Length
Date Format
Range
Constraints
Null Support
Default value
Domain
A
domain
has
a
logical
definition:
e.g.,
USA_phone_numbers are the set of 10 digit phone
numbers valid in the U.S.
The USA_phone_numbers may have a format: (ddd)ddd-dddd where each d is a decimal digit. E.g., Dates have
various formats such as monthname, date, year or yyyymm-dd, or dd mm,yyyy etc.
Chapter 5-12
Tuple
Extension
Intension
Degree
Cardinality
Slide 2-14
Chapte
r 5-15
DEFINITION SUMMARY
Informal Terms
Formal Terms
Table
Column
Row
Values in a column
Table Definition
Populated Table
Relation
Attribute/Domain
Tuple
Domain
Schema of a Relation
Extension
Relational Keys
There should not be any duplicate tuple within a
relation.
Therefore we should identify one or more
attributes(called relational keys) that uniquely
identify each tuple in a relation.
Types of Keys
Super Key
Candidate Key
Primary Key
Alternate Key
Artificial Key
Super Key
Are those attributes of a relation, which have the
properties of uniqueness.
Let us consider a relation R, by definition ,the set of
all attributes of R has the uniqueness property ,
meaning that, at any given time, no two tuples of
relation R are duplicates of one another.
Let K be a set of attributes of relation R.
Then K is a super key for R if and only if it posses
uniqueness.
Example
R=Student(Roll no., Name, Class)
Roll No.
Roll No.,Name
Roll No.,Class
Roll No.,Class,Name
Candidate Key
Are those attributes of a relation, which have the
Uniqueness
Irreducibility: No proper subset of K has the uniqueness
property.
Primary Key
It has three properties:
Uniqueness
Irreducibility
Not Null
Example
Student (Roll NO.,Name,Class,Mobile No.)
Identify candidate keys and a primary key.
Properties
Stable- The value of Primary Key must not change or
creation time.
Accessible: anyone who wants to create , read and
delete a record must be able to see the primary key
value.
Project ID
Hours_worked
01
01
200
01
02
120
02
01
50
02
03
120
03
03
100
03
04
200
Alternate Keys
Candidate keys which are not chosen or promoted as
Artificial Keys
An artificial key is the one that has no meaning to
Foreign Keys
Are the attributes of a table, which refers to the
Foreign Key
EMP
Emp No.
Ename
jOB
Sal
Dept NO
Clerk
4000
10
Clerk
4000
20
Mgr
8000
20
Peon
2000
40
Clerk
4000
10
Mgr
8000
50
Target
Attribute
or
Primary
Key
Dept No.
Dname
Loc
10
asr
20
Jal
30
Qadian
40
Dept
Or
Targe
t
Table
Referential Integrity
Foreign key values should always be matched by
Referential Integrity
Entity Integrity
Enterprise Constraints