Documente Academic
Documente Profesional
Documente Cultură
(Keys)
A relational Model is concerned with 3 components:
Data Structure
Data Integrity
Data Manipulation
Relational Data Structure
Relation:
Is a table with columns and rows.
All data and relationships are represented in a two
dimensional Table called a relation.
A relation consists of number of records or row wise
information and column wise information.
It represents the relation between the rows and columns
of a two dimensional table.
Attribute/ field:
An attribute is a named column of a relation.
A relation is represented as a two dimensional table in
which the rows of the table correspond to individual
records and the table columns correspond to attributes.
Attributes can appear in any order and the relation will
be the same relation and therefore covey the same
meaning.
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
domain information that includes:
Data type
Length
Date Format
Range
Constraints
Null Support
Default value
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
There is one more key, which is very imp. But it does
not hold the property of uniqueness and it is known
as Foreign 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)
Suppose Roll no. is unique.
1. Roll No.
2. Roll No.,Name
3. Roll No.,Class
4. Roll No.,Class,Name
Example
R=Student(Roll no., Name, Class)
Suppose Roll no. And Name are unique.
1. Roll No.
2. Roll No.,Name
3. Roll No.,Class
4. Roll No.,Class,Name
5. Name
6. Name,Class
Candidate Key
Are those attributes of a relation, which have the
properties of uniqueness and irreducibility.
Let K be a set of attributes of Relation R. Then K is a
candidate key for R if and only if it possesses both
properties:
Uniqueness
Irreducibility: No proper subset of K has the uniqueness
property.
1. Roll No.
2. Roll No.,Name
3. Roll No.,Class
4. Roll No.,Class,Name
Artificial Key
Foreign Keys
Are the attributes of a table, which refers to the
primary key of some other table.
Foreign Keys permit only those values, which appear
in the primary key of the table to which it refers and
may be null.
The foreign key is a reference to the tuple of a table
from which it is taken ,this tuple being called the
Referenced table .
Foreign Key
EMP
Emp No. Ename jOB Sal Dept NO
1 A Clerk 4000 10
2 A Clerk 4000 20
3 B Mgr 8000 20
4 C Peon 2000 40
5 D Clerk 4000 10
6 E Mgr 8000 50