Introduction To Relational Model
Introduction To Relational Model
tuples
(or rows)
Example of a Relation: teaches relation
Attribute
The set of allowed values for each attribute is called the domain
of the attribute
Roll #: Alphanumeric string
Fname, Lname: Alphabetic string
DoB: Date
Passport #: String (Letter followed by 7 digits)- nullable
Aadhaar #: 12-digit number
Department: Alphabetic string
Attribute values are (normally) required to be atomic; that is,
indivisible
The special value null is a member of every domain. It indicates
that the value is “unknown”
Students
Roll # Fname Lname DoB Passport # Aadhaar # Department
15CS1026 Lalit Dubey 27-Mar-1997 L4032464 172861749239 Computer
16EE3029 Jatin Chopra 17-Nov-1996 null 152861649112 Mathematics
Database Schema and Instance
A1, A2, A3…..,An are attributes
R (A1, A2, A3…..,An) is a relation schema
Example:
instructor (ID, name, dept_name, salary)
Formally, for given sets D1, D2,…….Dn, a relation r is a subset of
D1 x D2 x…….x Dn
The current values (relation instance) of a relation are specified by a
table
An element t of r is a tuple, represented by a row in a table
A finite set of tuples in the relational database system represents
relation instance
Database Schema and Instance
Students
Roll # Fname Lname DoB Passport # Aadhaar # Department
15CS1026 Lalit Dubey 27-Mar-1997 L4032464 172861749239 Computer
16EE3029 Jatin Chopra 17-Nov-1996 null 152861649112 Mathematics
16EC2016 Smriti Mongra 23-Dec-1996 G3200125 190852699005 Electronics
16CE4038 Ramdin Minz 21-Jan-1995 X8300127 165721079131 Civil
Keys
Simple Key: Consists of a single attribute
Composite Key: {Fname, Lname}
Consists of more than one attribute to uniquely identify an entity
One or more of the attributes, which make up the key, are not simple
keys in their own right
Students
Roll # Fname Lname DoB Passport # Aadhaar # Department
15CS1026 Lalit Dubey 27-Mar-1997 L4032464 172861749239 Computer
16EE3029 Jatin Chopra 17-Nov-1996 null 152861649112 Mathematics
16EC2016 Smriti Mongra 23-Dec-1996 G3200125 190852699005 Electronics
16CE4038 Ramdin Minz 21-Jan-1995 X8300127 165721079131 Civil
Keys
Foreign key constraint: Value in one relation must appear in another
relation
Referencing relation: Enrolment
Foreign keys- Roll#, Course#
Referenced relations: Students, Courses
Compound key: A compound key consists of more than one attribute to
uniquely identify an entity occurrence
Each attribute, which makes up the key, is a simple key in its own right
{Roll#, Course#}
Students
Roll # Fname Lname DoB Passport # Aadhaar # Department
Courses
Course# Course Name Credits L-T-P Department
Enrolment
Roll # Course# Instructor ID
Relational Query Languages
Procedural vs. Non-procedural (or Declarative) languages