Relational Database
Relational Database
D ATA B A S E
R E L AT I O N A L D ATA B A S E M O D E L
Relational data model is the primary data model, which is used widely
around the world for data storage and processing
This model is simple and it has all the properties and capabilities required
to process data with storage efficiency
R E L AT I O N A L M O D E L C O N C E P T S
Tables − In the relational data model, relations are saved in the format of Tables. A table has rows and
columns, where rows represent records and columns represent the attributes.
Tuple − A single row of a table, which contains a single record for that relation is called a tuple
Relation Key − Each row has one or more attributes, known as relation key, which can identify the row in
the relation uniquely
Attribute domain − Every attribute has some predefined value scope, known as attribute domain
R E L AT I O N A L D ATA B A S E
KEY CONSTRAINTS
CONSTRAINTS
OF
DOMAIN CONSTRAINTS
R E L AT I O N A L
D ATA B A S E
REFERENTIAL
INTEGRITY
CONSTRAINTS
KEY CONSTRAINTS
There must be at least one minimal subset of attributes in the relation,
which can identify a tuple uniquely. This minimal subset of attributes is
called key for that relation. If there are more than one such minimal
subsets, these are called candidate keys.
In a relation with a key attribute, no two tuples can have identical values
for key attributes
The same constraints have been tried to employ on the attributes of a relation
• Super Key
• Candidate Key
• Primary Key
• Composite Key
• Secondary or Alternate Key
• Foreign Key
• Non-Key Attribute
SUPER KEY
• Super Key is defined as a set of attributes within a table
that uniquely identifies each record within a table.
• Candidate keys are selected from the set of super keys, the
only thing we take care while selecting candidate key is: It
should not have any redundant attribute.
Candidate Key ↓
Student_ID Student_Cellphone Age Course Address
PRIMARY KEY
Primary Key ↓
Student_ID Student_Name Age Course Address
COMPOSITE KEY
Key that consist of two or more attributes that uniquely identify an entity
occurrence is called Composite key.
But any attribute that makes up the Composite key is not a simple key in its
own.
Composite Key ↓
Customer_ID Order_ID Sales_Detail
S E C O N D A R Y O R A LT E R N AT I V E K E Y
Out of all candidate keys, only one gets selected as primary key, remaining keys are known as
alternate or secondary keys.
Alternate
Key ↓
Student_ID Student_Cellphone Age Course Address
Primary Key ↑
FOREIGN KEY
• Foreign keys are the columns of a table that points to the primary
key of another table.
• They act as a cross-reference between tables.
Foreign Key ↓
Srudent_ID Course_ID
N O N - K E Y AT T R I B U T E
Non-key attributes are attributes other than candidate key
attributes in a table.
Non-Key Attribute ↓
Student_ID Student_Name Age Course Address