SlideShare a Scribd company logo
Learning Resource
On
Database Management Systems
Chapter-5
The Relational Data Model
Prepared By:
Kunal Anand, Asst. Professor
SCE, KIIT, DU, Bhubaneswar-24
Chapter Outcome:
• After the completion of this chapter, the students
will be able to:
– Define different relational model concepts
– Explain several keys in relational model
– Describe constraints in relational model
– Identify the characteristics of relational databases
– Convert ER model into relational model
16 March 2021 2
Organization of this Chapter:
• Introduction
• Relational Model Concepts
• Keys in Relational Model
• Relational Model Constraints
• Characteristics of Relational Model
• Relational Database and its Schema
• Logical Database Design: ER to Relational
16 March 2021 3
Introduction
• The relational data model was introduced by Ted Codd of IBM
Research in 1970.
• The relational data model enables even the novice users to
understand the database, and it permits the use of simple, high
level language to query the data.
• It became very popular in short span of time due to its
simplicity and mathematical foundation.
• The first commercial implementation of the relational data
model became available in early 80s, since then the model has
been implemented in a large number of open source systems.
• Current popular commercial RDBMSs include DB2 from
IBM, Oracle from oracle, Sybase DBMS (now SAP), and SQL
server and Microsoft Access from Microsoft.
16 March 2021 4
Relational Model Concepts
• The main construct to represent the data in the relational
model is a “Relation” which is used to refer to a table.
• In a relation or table, a column header is called an
“attribute”, and a row is called a “tuple”.
• Mathematically, a tuple is a sequence of values. A relationship
between n values can be represented by n-tuples i.e. a tuple of
n values, which corresponds to a row in the table.
• A relational schema contains the name of the relation and
name of all columns or attributes.
• In a relational schema, a domain is referred to by the domain
name and has a set of associated values.
16 March 2021 5
contd..
• In the relational database system, the relational instance is
represented by a finite set of tuples. Relational instances do not
have duplicate tuples.
• The degree is the number of attributes/columns in a table,
whereas cardinality is the number of tuples/rows in a table.
• In a relation, each row has one or more attributes that can
identify the row in the relation uniquely. This is known as
relational key.
• NULL Values: The value which is not known or unavailable is
called NULL value. It is represented by blank space.
16 March 2021 6
contd..
16 March 2021 7
The Instructor Relation
• The instructor relation is represented using the instructor
table, which stores information about the instructors.
• The instructor table has 4 column headers: ID, name,
dept_name, and salary i.e. the table has 4 attributes.
• Each row or tuple of this table records information about an
instructor, consisting of the fields specified in the table.
– t1 = <10101, Srinivasan, Comp. Sci., 65000>
• The relational schema for the instructor table can be
Instructor(ID char, name varchar2, dept_name
varchar2, salary integer)
• The instructor table has an attribute “ID” that can be
considered as relational key as it uniquely identifies each
tuple of the table.
16 March 2021 8
Keys in Relational Model
• Keys play an important role in the relational database.
• A key is a property of the relation, rather than of the tuple.
• It is used to uniquely identify any record or row of data from
the table. It is also used to establish and identify relationships
between tables.
• Usually, following types of keys exist in relational model
16 March 2021 9
Types of Key
• A super key is a set of one or more attributes that allows us to
uniquely identify a tuple in a relation i.e. table.
• A candidate key is a minimal set of super key that cannot have
any columns removed from it without losing the unique
identification property. This property is sometimes known as
minimality or (better) irreducibility.
• All candidate key is super key but the reverse is not true.
16 March 2021 10
contd..
• Primary key is a candidate key that is chosen by the database
designer as the principal means of identifying tuples in a table.
– The primary key should be chosen such that its attributes
are never or very rarely changed.
• The remaining candidate keys, except the primary key, are
called as Alternate keys.
• If none of the columns is a candidate for the primary key in a
table, sometimes database designers use an extra column as a
primary key instead of using a composite key. Such key is
known as the Surrogate key.
• Foreign key is the set of attributes that is used to refer to
another entity set having the primary key.
– In ER diagram, foreign key can not be represented. Foreign
Key is specifically for relational model.
16 March 2021 11
An Example
16 March 2021 12
contd..
• Super Key (SK)
– For Example, the STUDENT table has a super key, SK as
(STUD_NO, STUD_PHONE)
• Candidate Key (CK)
– For Example, STUD_NO, and STUD_PHONE in
STUDENT relation.
– There can be more than one candidate key in a relation. For
Example, STUD_NO as well as STUD_PHONE both are
candidate keys for relation STUDENT.
– The candidate key can be simple (having only one
attribute) or composite as well.
• For Example, {STUD_NO, COURSE_NO} is a composite
candidate key for relation STUDENT_COURSE.
16 March 2021 13
contd..
• Primary Key
– For Example, STUD_NO as well as STUD_PHONE both
are candidate keys for relation STUDENT but STUD_NO
can be chosen as primary key. Why not
STUD_PHONE???
• Alternate Key
– For Example, STUD_NO as well as STUD_PHONE both
are candidate keys for relation STUDENT and STUD_NO
is selected as primary key. So, STUD_PHONE will be
alternate key.
• Foreign Key
– For Example, STUD_NO in STUDENT_COURSE is a
foreign key to STUD_NO in STUDENT relation.
16 March 2021 14
Relational Model Constraints
• Operational Constraints are enforced in the database by the
business rules or real world limitations.
• Relational Data Integrity: Candidate key is an attribute or set
of attributes that can uniquely identify a row or tuple in a table.
– Let R be the relation with attributes a1, a2 ... an . The set of
attributes of R is said to be a candidate key of R iff the
following two properties holds:
• Uniqueness: At any given time, no two distinct tuples or
rows of R have the same value for ai , the same value for
aj ...an
• Minimality: No proper subset of the set (ai , aj ... an ) has
the uniqueness property
16 March 2021 15
Integrity Constraints
• Integrity constraints are a set of rules that is used to maintain
the quality of information.
• Integrity constraints ensure that the data insertion, updation,
and other processes are performed in such a way that data
integrity is not affected.
• Thus, integrity constraint is used to guard against accidental
damage to the database.
16 March 2021 16
contd..
• Domain Constraint
– They can be defined as the definition of a valid set of
values for an attribute.
– The data type of domain includes string, character, integer,
time, date, currency, etc. The value of the attribute must be
available in the corresponding domain.
16 March 2021 17
contd..
• Entity Integrity Constraint
– The entity integrity constraint states that primary key value
can't be null. A table can contain a null value other than the
primary key field.
– This is because the primary key value is used to identify
individual rows in relation and if the primary key has a null
value, then we can't identify those rows.
16 March 2021 18
contd..
• Referential Integrity Constraint: A referential integrity
constraint is specified between two tables.
– In the Referential integrity constraints, if a foreign key in Table 1 refers
to the Primary Key of Table 2, then every value of the Foreign Key in
Table 1 must be null or be available in Table 2.
– A foreign key which references its own relation is known as recursive
foreign key.
16 March 2021 19
contd..
• Key constraints
– Keys are the entity set that is used to identify an entity
within its entity set uniquely.
– An entity set can have multiple keys, but out of which one
key will be the primary key. A primary key can contain a
unique and null value in the relational table.
16 March 2021 20
Database Languages
• Data Definition Language (DDL)
– DDL is used to define the conceptual schema.
– The output of the DDL is placed in the Data Dictionary that
contains the metadata(data about data).
– The data dictionary is considered to be a special type of
table, which can only be accessed and updated by the
database system itself.
– The database system consults the data dictionary, before
querying or modifying the actual data, for the validation
purpose.
– Commands: CREATE, ALTER, DROP, RENAME &
TRUNCATE
16 March 2021 21
contd..
• DML (Data Manipulation Language)
– DML is used to manipulate data in the database.
– A query is a statement in the DML that requests the
retrieval of data from the database.
– Commands: SELECT, INSERT, UPDATE & DELETE
• DCL (Data Control Languages)
•DCL allows in changing the permissions on database
structures
•Commands: GRANT & REVOKE
• TCL (Transaction Control Language)
•TCL allows permanently recording the changes made to the
rows stored in a table or undoing such changes
•Commands: COMMIT, ROLLBACK & SAVEPOINT
16 March 2021 22
Characteristics of Relational Database
• Relational database consists of multiple relations or tables.
• The information about an enterprise is broken up into parts,
with each relation storing one part of the information
• The characteristics of relational database is expressed by
Codd in the form of a set of rules that is widely known as
CODD's Rules.
• CODD's Rules
– Rule 0: A relational system should be able to manage
databases, entirely through its relational capabilities.
16 March 2021 23
contd..
– Rule 1: Information representation
• The entire information is explicitly and logically
represented by the data values of the tables in the
relational data model.
– Rule 2: Guaranteed access
• In relational model, the interaction of each row and
column will have one and only one value of data (or
NULL value).
• Each value of data must be addressable via the
combination of a table name, primary key value and the
column name.
– Rule 3: Systematic treatment of NULL values
• NULL values are supported in fully relational DBMS
for to represent missing information and inapplicable
information in a systematic way independent of data
type.
16 March 2021 24
contd..
– Rule 4: Database description rule
• The database description is represented at the logical level
in the same way as ordinary data, so that authorized users
can apply the same relational language to its interrogation
as they apply to the regular data.
• This means, the RDBMS must have a data dictionary.
• Rule 5: Comprehensive data sub-language
– The RDBMS should have its own extension of SQL.
– The SQL should support Data Definition, View Definition,
Data Manipulation, Integrity Constraint, and Authorization.
• Rule 6: Views updation
– All views that are theoretically updatable are also updatable by
the system. Similarly, the views which are theoretically non-
updatable are also non-updatable by the database system.
16 March 2021 25
contd..
• Rule 7: High-level update, insert, deletes
– A RDBMS should not only support retrieval of data as
relational sets, but also insertion, updation and deletion of
data as a relational set.
• Rule 8: Physical data independence
– Application programs and terminal activities are not
disturbed if any changes are made either to storage
representations or access methods.
• Rule 9: Logical data independence
– User programs and the user should not be aware of any
changes to the structure of the tables such as the addition of
extra columns.
16 March 2021 26
contd..
• Rule 10: Distribution independence
– RDBMS has distribution independence. The RDBMS may
spread across more than one system and across several
networks. However to the end-user, the tables should appear
no different to those that are local.
• Rule 11: Integrity Rules
– Integrity rules must be supported by the database and the
constraints must be stored within the catalogue, separate
from the application.
• Rule 12: Data integrity cannot be subverted
– If a relational system has a low-level language, that low
level cannot be used to subvert or bypass the integrity
rules.
16 March 2021 27
Relational Database and its Schema
• Relational database consists of multiple relations or tables.
• The information about an enterprise is broken up into parts,
with each relation storing one part of the information.
• A relational schema contains the name of the relation and
name of all columns or attributes.
• For the complete database, it is known as relational database
schema that is actually a collection of different schemas that
refers to different relations or tables available in the database.
16 March 2021 28
contd..
• For example: A UNIVERSITY database can have a relational
database schema as below:
– student(ID, name, dept_name, tot_cred)
– advisor(s_id,i_id)
– teaches(ID, course_ID, sec_ID, semester, year)
– takes(ID, course_ID,sec_ID,semester, year, grade)
– section(course_ID, sec_ID, semester, year, building, room_no,
time_slot_id)
– timeslot(time_slot_id, day, start_time, end_time)
– prereq(course_ID, prereq_ID)
– classroom(building, room_number,capacity)
– department(dept_name, building, budget)
– instructor(ID, name, dept_name, salary)
– course(course_ID, title,dept_name,credits)
16 March 2021 29
Relational Schema Diagram
16 March 2021 30
Conversion of ER Diagram to Relational
Schema
• A database that conforms to an ER diagram can be represented
by a collection of relational schemas.
• Both, the ER model and Relational data model are abstract i.e.
logical representations of real-world enterprises.
• Converting Strong entity types
 Each entity type becomes a table
 Each single-valued attribute becomes a column
 Derived attributes are ignored
 Composite attributes are represented by components
 Multi-valued attributes are represented by a separate table
 The key attribute of the entity type becomes the primary
key of the table
16 March 2021 31
Converting Entity Types
16 March 2021 32
Converting weak entity types
16 March 2021 33
Converting Relationships
• The way relationships are represented depends on the
cardinality and the degree of the relationship.
• The possible cardinalities are:
1:1, 1:N, N:1, M:N
• The degrees are:
Unary
Binary
Ternary …
16 March 2021 34
Binary 1:1
16 March 2021 35
contd..
16 March 2021 36
Binary 1:N / N:1
16 March 2021 37
Binary M:N
16 March 2021 38
Unary 1:1
16 March 2021 39
Unary 1:N
16 March 2021 40
Unary M:N
16 March 2021 41
Ternary relationship
16 March 2021 42
Case Study: Company Database
• Problem Statement: The COMPANY database problem has
been discussed in Ch-3: Data Modeling using ER Model.
• The ER details of the Company Database is as below:
– EMPLOYEE (Entity Type)
• Attribute: Emp_name, Emp_ID, SSN, age, address,
gender, salary, DOB, and supervisor
– DEPARTMENT (Entity Type)
• Attribute: Name, Number, Location, Manager, and
Manager_start_date
– PROJECT (Entity Type)
• Attribute: Name, Number, Location, Controlling_dept
– DEPENDENT (Entity Type)
• Attribute: Name, gender, DOB, Employee,
Relationship
16 March 2021 43
contd..
– MANAGES:
• Binary and 1:1 Cardinality
• Entity types: EMPLOYEE and DEPARTMENT
• Participation: EMPLOYEE (Partial); DEPARTMENT
(Total)
– WORKS_FOR:
• Binary and N:1 Cardinality
• Entity types: EMPLOYEE and DEPARTMENT
– CONTROLS:
• Binary and 1:N Cardinality
• Entity types: DEPARTMENT and PROJECT
16 March 2021 44
contd..
– SUPERVISION:
• Unary and 1:N Cardinality
• Entity types: EMPLOYEE
– WORKS_ON:
• Binary and M:N Cardinality
• Entity types: EMPLOYEE and PROJECT
– DEPENDENTS_OF:
• Binary and 1:N Cardinality
• Entity types: EMPLOYEE and DEPENDENT
16 March 2021 45
Case Study: Relational Schema
• Employee(Emp_name, Emp_ID, SSN, address, gender, salary,
DOB, supervisor, Dept_ID)
• Department(Name, Dept_ID, Location, Manager, and
Manager_start_date)
• Project(Name, Proj_ID, Location, Controlling_dept)
• Dependent(Name, gender, DOB, Relationship, Emp_ID)
• Works_On(Emp_ID, Proj_ID, no_of_hrs, supervisor)
Note: Attributes in “Red” are the FOREIGN KEY in that table
16 March 2021 46
Relational Schema Diagram
16 March 2021 47
Representation of Generalization/Specialization
• In case of generalization/specialization-related ER diagram,
one schema will be constructed for the generalized entity set
and the schemas for each of the specialized entity sets
• Person = (person_id, name, address)
• Employee = (emp_id, salary)
• Customer = (cust_id, credit_rating)
16 March 2021 48
contd..
• When the generalization/specialization is a disjointness case,
the schemas are constructed only for the specialized entity sets
– Employee = (employee_id, name, address, salary)
– Customer = (customer_id, name, address, credit_rating)
• Representation of Aggregation
– To represent aggregation, create a schema containing the
primary key of the aggregated relationship, primary key of
the associated entity set and descriptive attributes (if any)
16 March 2021 49
contd..
•Employee = (eid, name, address)
•Branch = (bid, bname, asset)
•Job = (jobid, position, responsibility)
• Works_on = (eid, bid, jobid)
• Manager = (mid, mgrname)
• Manages = (eid, bid, jobid, mid)
16 March 2021 50

More Related Content

What's hot

Relational model
Relational modelRelational model
Relational model
Dabbal Singh Mahara
 
Presentation on Relational Schema (Database)
Presentation on Relational Schema (Database)Presentation on Relational Schema (Database)
Presentation on Relational Schema (Database)
Salim Hosen
 
Integrity Constraints
Integrity ConstraintsIntegrity Constraints
Integrity Constraints
madhav bansal
 
Functional dependancy
Functional dependancyFunctional dependancy
Functional dependancy
Visakh V
 
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with ExamplesDML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
LGS, GBHS&IC, University Of South-Asia, TARA-Technologies
 
4 the relational data model and relational database constraints
4 the relational data model and relational database constraints4 the relational data model and relational database constraints
4 the relational data model and relational database constraintsKumar
 
Introduction to structured query language (sql)
Introduction to structured query language (sql)Introduction to structured query language (sql)
Introduction to structured query language (sql)
Sabana Maharjan
 
Logical database design and the relational model(database)
Logical database design and the relational model(database)Logical database design and the relational model(database)
Logical database design and the relational model(database)welcometofacebook
 
Database
DatabaseDatabase
Functional dependencies and normalization
Functional dependencies and normalizationFunctional dependencies and normalization
Functional dependencies and normalizationdaxesh chauhan
 
Normal forms
Normal formsNormal forms
Normal forms
Samuel Igbanogu
 
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...
Raj vardhan
 
joins in database
 joins in database joins in database
joins in database
Sultan Arshad
 
Normalization
NormalizationNormalization
Normalization
Salman Memon
 
Introduction to structured query language (sql)
Introduction to structured query language (sql)Introduction to structured query language (sql)
Introduction to structured query language (sql)
Dhani Ahmad
 
The relational data model part[1]
The relational data model part[1]The relational data model part[1]
The relational data model part[1]
Bashir Rezaie
 
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NFDatabase Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
Oum Saokosal
 
Relational algebra.pptx
Relational algebra.pptxRelational algebra.pptx
Relational algebra.pptx
RUpaliLohar
 
Fundamentals of Database ppt ch02
Fundamentals of Database ppt ch02Fundamentals of Database ppt ch02
Fundamentals of Database ppt ch02Jotham Gadot
 

What's hot (20)

Relational model
Relational modelRelational model
Relational model
 
Ch1
Ch1Ch1
Ch1
 
Presentation on Relational Schema (Database)
Presentation on Relational Schema (Database)Presentation on Relational Schema (Database)
Presentation on Relational Schema (Database)
 
Integrity Constraints
Integrity ConstraintsIntegrity Constraints
Integrity Constraints
 
Functional dependancy
Functional dependancyFunctional dependancy
Functional dependancy
 
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with ExamplesDML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
 
4 the relational data model and relational database constraints
4 the relational data model and relational database constraints4 the relational data model and relational database constraints
4 the relational data model and relational database constraints
 
Introduction to structured query language (sql)
Introduction to structured query language (sql)Introduction to structured query language (sql)
Introduction to structured query language (sql)
 
Logical database design and the relational model(database)
Logical database design and the relational model(database)Logical database design and the relational model(database)
Logical database design and the relational model(database)
 
Database
DatabaseDatabase
Database
 
Functional dependencies and normalization
Functional dependencies and normalizationFunctional dependencies and normalization
Functional dependencies and normalization
 
Normal forms
Normal formsNormal forms
Normal forms
 
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...
The Relational Data Model and Relational Database Constraints Ch5 (Navathe 4t...
 
joins in database
 joins in database joins in database
joins in database
 
Normalization
NormalizationNormalization
Normalization
 
Introduction to structured query language (sql)
Introduction to structured query language (sql)Introduction to structured query language (sql)
Introduction to structured query language (sql)
 
The relational data model part[1]
The relational data model part[1]The relational data model part[1]
The relational data model part[1]
 
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NFDatabase Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
 
Relational algebra.pptx
Relational algebra.pptxRelational algebra.pptx
Relational algebra.pptx
 
Fundamentals of Database ppt ch02
Fundamentals of Database ppt ch02Fundamentals of Database ppt ch02
Fundamentals of Database ppt ch02
 

Similar to Chapter-5 The Relational Data Model

DATABASE DESIGN.pptx
DATABASE DESIGN.pptxDATABASE DESIGN.pptx
DATABASE DESIGN.pptx
SaranCreations
 
Unit 2 DBMS.pptx
Unit 2 DBMS.pptxUnit 2 DBMS.pptx
Unit 2 DBMS.pptx
ssuserc8e1481
 
DBMS:Relational Modal
DBMS:Relational ModalDBMS:Relational Modal
DBMS:Relational Modal
VaishnaviVaishnavi17
 
Relational Database.pptx
Relational Database.pptxRelational Database.pptx
Relational Database.pptx
SubhamSarkar64
 
Relational database (Unit 2)
Relational database (Unit 2)Relational database (Unit 2)
Relational database (Unit 2)
Ismail Mukiibi
 
demo2.ppt
demo2.pptdemo2.ppt
demo2.ppt
crazyvirtue
 
Database Concepts.pptx
Database Concepts.pptxDatabase Concepts.pptx
Database Concepts.pptx
DhruvSavaliya9
 
Dbms relational data model and sql queries
Dbms relational data model and sql queries Dbms relational data model and sql queries
Dbms relational data model and sql queries
Tetala Vishnu Vardhan Reddy
 
DB2 on Mainframe
DB2 on MainframeDB2 on Mainframe
DB2 on Mainframe
Skillwise Group
 
Unit 2_DBMS_10.2.22.pptx
Unit 2_DBMS_10.2.22.pptxUnit 2_DBMS_10.2.22.pptx
Unit 2_DBMS_10.2.22.pptx
MaryJoseph79
 
DBMS
DBMSDBMS
DBMS
emran nur
 
ch2-slide Data Models.pptx
ch2-slide Data Models.pptxch2-slide Data Models.pptx
ch2-slide Data Models.pptx
TamiratDejene1
 
Chapter – 3 Database Design P-I.pdf
Chapter – 3 Database Design P-I.pdfChapter – 3 Database Design P-I.pdf
Chapter – 3 Database Design P-I.pdf
TamiratDejene1
 
Unit I Database concepts - RDBMS & ORACLE
Unit I  Database concepts - RDBMS & ORACLEUnit I  Database concepts - RDBMS & ORACLE
Unit I Database concepts - RDBMS & ORACLE
DrkhanchanaR
 
ER Digramms by Harshal wagh
ER Digramms by Harshal waghER Digramms by Harshal wagh
ER Digramms by Harshal wagh
harshalkwagh999
 
Structured system analysis and design
Structured system analysis and design Structured system analysis and design
Structured system analysis and design
Jayant Dalvi
 
DATABASE-1.pptx
DATABASE-1.pptxDATABASE-1.pptx
DATABASE-1.pptx
ManasRanjanRana4
 
Data Base Management System.pdf
Data Base Management System.pdfData Base Management System.pdf
Data Base Management System.pdf
TENZING LHADON
 
Dbms 9: Relational Model
Dbms 9: Relational ModelDbms 9: Relational Model
Dbms 9: Relational Model
Amiya9439793168
 
NMEC RD_UNIT 1.ppt
NMEC RD_UNIT 1.pptNMEC RD_UNIT 1.ppt
NMEC RD_UNIT 1.ppt
IswaryaPurushothaman1
 

Similar to Chapter-5 The Relational Data Model (20)

DATABASE DESIGN.pptx
DATABASE DESIGN.pptxDATABASE DESIGN.pptx
DATABASE DESIGN.pptx
 
Unit 2 DBMS.pptx
Unit 2 DBMS.pptxUnit 2 DBMS.pptx
Unit 2 DBMS.pptx
 
DBMS:Relational Modal
DBMS:Relational ModalDBMS:Relational Modal
DBMS:Relational Modal
 
Relational Database.pptx
Relational Database.pptxRelational Database.pptx
Relational Database.pptx
 
Relational database (Unit 2)
Relational database (Unit 2)Relational database (Unit 2)
Relational database (Unit 2)
 
demo2.ppt
demo2.pptdemo2.ppt
demo2.ppt
 
Database Concepts.pptx
Database Concepts.pptxDatabase Concepts.pptx
Database Concepts.pptx
 
Dbms relational data model and sql queries
Dbms relational data model and sql queries Dbms relational data model and sql queries
Dbms relational data model and sql queries
 
DB2 on Mainframe
DB2 on MainframeDB2 on Mainframe
DB2 on Mainframe
 
Unit 2_DBMS_10.2.22.pptx
Unit 2_DBMS_10.2.22.pptxUnit 2_DBMS_10.2.22.pptx
Unit 2_DBMS_10.2.22.pptx
 
DBMS
DBMSDBMS
DBMS
 
ch2-slide Data Models.pptx
ch2-slide Data Models.pptxch2-slide Data Models.pptx
ch2-slide Data Models.pptx
 
Chapter – 3 Database Design P-I.pdf
Chapter – 3 Database Design P-I.pdfChapter – 3 Database Design P-I.pdf
Chapter – 3 Database Design P-I.pdf
 
Unit I Database concepts - RDBMS & ORACLE
Unit I  Database concepts - RDBMS & ORACLEUnit I  Database concepts - RDBMS & ORACLE
Unit I Database concepts - RDBMS & ORACLE
 
ER Digramms by Harshal wagh
ER Digramms by Harshal waghER Digramms by Harshal wagh
ER Digramms by Harshal wagh
 
Structured system analysis and design
Structured system analysis and design Structured system analysis and design
Structured system analysis and design
 
DATABASE-1.pptx
DATABASE-1.pptxDATABASE-1.pptx
DATABASE-1.pptx
 
Data Base Management System.pdf
Data Base Management System.pdfData Base Management System.pdf
Data Base Management System.pdf
 
Dbms 9: Relational Model
Dbms 9: Relational ModelDbms 9: Relational Model
Dbms 9: Relational Model
 
NMEC RD_UNIT 1.ppt
NMEC RD_UNIT 1.pptNMEC RD_UNIT 1.ppt
NMEC RD_UNIT 1.ppt
 

More from Kunal Anand

Chapter-10 Transaction Processing and Error Recovery
Chapter-10 Transaction Processing and Error RecoveryChapter-10 Transaction Processing and Error Recovery
Chapter-10 Transaction Processing and Error Recovery
Kunal Anand
 
Chapter-9 Normalization
Chapter-9 NormalizationChapter-9 Normalization
Chapter-9 Normalization
Kunal Anand
 
Chapter-8 Relational Database Design
Chapter-8 Relational Database DesignChapter-8 Relational Database Design
Chapter-8 Relational Database Design
Kunal Anand
 
Chapter-7 Relational Calculus
Chapter-7 Relational CalculusChapter-7 Relational Calculus
Chapter-7 Relational Calculus
Kunal Anand
 
Chapter-6 Relational Algebra
Chapter-6 Relational AlgebraChapter-6 Relational Algebra
Chapter-6 Relational Algebra
Kunal Anand
 
Chapter-4 Enhanced ER Model
Chapter-4 Enhanced ER ModelChapter-4 Enhanced ER Model
Chapter-4 Enhanced ER Model
Kunal Anand
 
Chapter-3 Data Modeling using ER Model
Chapter-3 Data Modeling using ER ModelChapter-3 Data Modeling using ER Model
Chapter-3 Data Modeling using ER Model
Kunal Anand
 
Chapter-2 Database System Concepts and Architecture
Chapter-2 Database System Concepts and ArchitectureChapter-2 Database System Concepts and Architecture
Chapter-2 Database System Concepts and Architecture
Kunal Anand
 
Chapter-1 Introduction to Database Management Systems
Chapter-1 Introduction to Database Management SystemsChapter-1 Introduction to Database Management Systems
Chapter-1 Introduction to Database Management Systems
Kunal Anand
 

More from Kunal Anand (9)

Chapter-10 Transaction Processing and Error Recovery
Chapter-10 Transaction Processing and Error RecoveryChapter-10 Transaction Processing and Error Recovery
Chapter-10 Transaction Processing and Error Recovery
 
Chapter-9 Normalization
Chapter-9 NormalizationChapter-9 Normalization
Chapter-9 Normalization
 
Chapter-8 Relational Database Design
Chapter-8 Relational Database DesignChapter-8 Relational Database Design
Chapter-8 Relational Database Design
 
Chapter-7 Relational Calculus
Chapter-7 Relational CalculusChapter-7 Relational Calculus
Chapter-7 Relational Calculus
 
Chapter-6 Relational Algebra
Chapter-6 Relational AlgebraChapter-6 Relational Algebra
Chapter-6 Relational Algebra
 
Chapter-4 Enhanced ER Model
Chapter-4 Enhanced ER ModelChapter-4 Enhanced ER Model
Chapter-4 Enhanced ER Model
 
Chapter-3 Data Modeling using ER Model
Chapter-3 Data Modeling using ER ModelChapter-3 Data Modeling using ER Model
Chapter-3 Data Modeling using ER Model
 
Chapter-2 Database System Concepts and Architecture
Chapter-2 Database System Concepts and ArchitectureChapter-2 Database System Concepts and Architecture
Chapter-2 Database System Concepts and Architecture
 
Chapter-1 Introduction to Database Management Systems
Chapter-1 Introduction to Database Management SystemsChapter-1 Introduction to Database Management Systems
Chapter-1 Introduction to Database Management Systems
 

Recently uploaded

English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
BrazilAccount1
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Teleport Manpower Consultant
 
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERSCW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
veerababupersonal22
 
6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)
ClaraZara1
 
AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
BrazilAccount1
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
Intella Parts
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTSHeap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Soumen Santra
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
ydteq
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
zwunae
 
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdfTutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
aqil azizi
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
TeeVichai
 
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
ssuser7dcef0
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
FluxPrime1
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
AJAYKUMARPUND1
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
VENKATESHvenky89705
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Dr.Costas Sachpazis
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 

Recently uploaded (20)

English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
 
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERSCW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
 
6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)
 
AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTSHeap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
 
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdfTutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
 
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 

Chapter-5 The Relational Data Model

  • 1. Learning Resource On Database Management Systems Chapter-5 The Relational Data Model Prepared By: Kunal Anand, Asst. Professor SCE, KIIT, DU, Bhubaneswar-24
  • 2. Chapter Outcome: • After the completion of this chapter, the students will be able to: – Define different relational model concepts – Explain several keys in relational model – Describe constraints in relational model – Identify the characteristics of relational databases – Convert ER model into relational model 16 March 2021 2
  • 3. Organization of this Chapter: • Introduction • Relational Model Concepts • Keys in Relational Model • Relational Model Constraints • Characteristics of Relational Model • Relational Database and its Schema • Logical Database Design: ER to Relational 16 March 2021 3
  • 4. Introduction • The relational data model was introduced by Ted Codd of IBM Research in 1970. • The relational data model enables even the novice users to understand the database, and it permits the use of simple, high level language to query the data. • It became very popular in short span of time due to its simplicity and mathematical foundation. • The first commercial implementation of the relational data model became available in early 80s, since then the model has been implemented in a large number of open source systems. • Current popular commercial RDBMSs include DB2 from IBM, Oracle from oracle, Sybase DBMS (now SAP), and SQL server and Microsoft Access from Microsoft. 16 March 2021 4
  • 5. Relational Model Concepts • The main construct to represent the data in the relational model is a “Relation” which is used to refer to a table. • In a relation or table, a column header is called an “attribute”, and a row is called a “tuple”. • Mathematically, a tuple is a sequence of values. A relationship between n values can be represented by n-tuples i.e. a tuple of n values, which corresponds to a row in the table. • A relational schema contains the name of the relation and name of all columns or attributes. • In a relational schema, a domain is referred to by the domain name and has a set of associated values. 16 March 2021 5
  • 6. contd.. • In the relational database system, the relational instance is represented by a finite set of tuples. Relational instances do not have duplicate tuples. • The degree is the number of attributes/columns in a table, whereas cardinality is the number of tuples/rows in a table. • In a relation, each row has one or more attributes that can identify the row in the relation uniquely. This is known as relational key. • NULL Values: The value which is not known or unavailable is called NULL value. It is represented by blank space. 16 March 2021 6
  • 8. The Instructor Relation • The instructor relation is represented using the instructor table, which stores information about the instructors. • The instructor table has 4 column headers: ID, name, dept_name, and salary i.e. the table has 4 attributes. • Each row or tuple of this table records information about an instructor, consisting of the fields specified in the table. – t1 = <10101, Srinivasan, Comp. Sci., 65000> • The relational schema for the instructor table can be Instructor(ID char, name varchar2, dept_name varchar2, salary integer) • The instructor table has an attribute “ID” that can be considered as relational key as it uniquely identifies each tuple of the table. 16 March 2021 8
  • 9. Keys in Relational Model • Keys play an important role in the relational database. • A key is a property of the relation, rather than of the tuple. • It is used to uniquely identify any record or row of data from the table. It is also used to establish and identify relationships between tables. • Usually, following types of keys exist in relational model 16 March 2021 9
  • 10. Types of Key • A super key is a set of one or more attributes that allows us to uniquely identify a tuple in a relation i.e. table. • A candidate key is a minimal set of super key that cannot have any columns removed from it without losing the unique identification property. This property is sometimes known as minimality or (better) irreducibility. • All candidate key is super key but the reverse is not true. 16 March 2021 10
  • 11. contd.. • Primary key is a candidate key that is chosen by the database designer as the principal means of identifying tuples in a table. – The primary key should be chosen such that its attributes are never or very rarely changed. • The remaining candidate keys, except the primary key, are called as Alternate keys. • If none of the columns is a candidate for the primary key in a table, sometimes database designers use an extra column as a primary key instead of using a composite key. Such key is known as the Surrogate key. • Foreign key is the set of attributes that is used to refer to another entity set having the primary key. – In ER diagram, foreign key can not be represented. Foreign Key is specifically for relational model. 16 March 2021 11
  • 13. contd.. • Super Key (SK) – For Example, the STUDENT table has a super key, SK as (STUD_NO, STUD_PHONE) • Candidate Key (CK) – For Example, STUD_NO, and STUD_PHONE in STUDENT relation. – There can be more than one candidate key in a relation. For Example, STUD_NO as well as STUD_PHONE both are candidate keys for relation STUDENT. – The candidate key can be simple (having only one attribute) or composite as well. • For Example, {STUD_NO, COURSE_NO} is a composite candidate key for relation STUDENT_COURSE. 16 March 2021 13
  • 14. contd.. • Primary Key – For Example, STUD_NO as well as STUD_PHONE both are candidate keys for relation STUDENT but STUD_NO can be chosen as primary key. Why not STUD_PHONE??? • Alternate Key – For Example, STUD_NO as well as STUD_PHONE both are candidate keys for relation STUDENT and STUD_NO is selected as primary key. So, STUD_PHONE will be alternate key. • Foreign Key – For Example, STUD_NO in STUDENT_COURSE is a foreign key to STUD_NO in STUDENT relation. 16 March 2021 14
  • 15. Relational Model Constraints • Operational Constraints are enforced in the database by the business rules or real world limitations. • Relational Data Integrity: Candidate key is an attribute or set of attributes that can uniquely identify a row or tuple in a table. – Let R be the relation with attributes a1, a2 ... an . The set of attributes of R is said to be a candidate key of R iff the following two properties holds: • Uniqueness: At any given time, no two distinct tuples or rows of R have the same value for ai , the same value for aj ...an • Minimality: No proper subset of the set (ai , aj ... an ) has the uniqueness property 16 March 2021 15
  • 16. Integrity Constraints • Integrity constraints are a set of rules that is used to maintain the quality of information. • Integrity constraints ensure that the data insertion, updation, and other processes are performed in such a way that data integrity is not affected. • Thus, integrity constraint is used to guard against accidental damage to the database. 16 March 2021 16
  • 17. contd.. • Domain Constraint – They can be defined as the definition of a valid set of values for an attribute. – The data type of domain includes string, character, integer, time, date, currency, etc. The value of the attribute must be available in the corresponding domain. 16 March 2021 17
  • 18. contd.. • Entity Integrity Constraint – The entity integrity constraint states that primary key value can't be null. A table can contain a null value other than the primary key field. – This is because the primary key value is used to identify individual rows in relation and if the primary key has a null value, then we can't identify those rows. 16 March 2021 18
  • 19. contd.. • Referential Integrity Constraint: A referential integrity constraint is specified between two tables. – In the Referential integrity constraints, if a foreign key in Table 1 refers to the Primary Key of Table 2, then every value of the Foreign Key in Table 1 must be null or be available in Table 2. – A foreign key which references its own relation is known as recursive foreign key. 16 March 2021 19
  • 20. contd.. • Key constraints – Keys are the entity set that is used to identify an entity within its entity set uniquely. – An entity set can have multiple keys, but out of which one key will be the primary key. A primary key can contain a unique and null value in the relational table. 16 March 2021 20
  • 21. Database Languages • Data Definition Language (DDL) – DDL is used to define the conceptual schema. – The output of the DDL is placed in the Data Dictionary that contains the metadata(data about data). – The data dictionary is considered to be a special type of table, which can only be accessed and updated by the database system itself. – The database system consults the data dictionary, before querying or modifying the actual data, for the validation purpose. – Commands: CREATE, ALTER, DROP, RENAME & TRUNCATE 16 March 2021 21
  • 22. contd.. • DML (Data Manipulation Language) – DML is used to manipulate data in the database. – A query is a statement in the DML that requests the retrieval of data from the database. – Commands: SELECT, INSERT, UPDATE & DELETE • DCL (Data Control Languages) •DCL allows in changing the permissions on database structures •Commands: GRANT & REVOKE • TCL (Transaction Control Language) •TCL allows permanently recording the changes made to the rows stored in a table or undoing such changes •Commands: COMMIT, ROLLBACK & SAVEPOINT 16 March 2021 22
  • 23. Characteristics of Relational Database • Relational database consists of multiple relations or tables. • The information about an enterprise is broken up into parts, with each relation storing one part of the information • The characteristics of relational database is expressed by Codd in the form of a set of rules that is widely known as CODD's Rules. • CODD's Rules – Rule 0: A relational system should be able to manage databases, entirely through its relational capabilities. 16 March 2021 23
  • 24. contd.. – Rule 1: Information representation • The entire information is explicitly and logically represented by the data values of the tables in the relational data model. – Rule 2: Guaranteed access • In relational model, the interaction of each row and column will have one and only one value of data (or NULL value). • Each value of data must be addressable via the combination of a table name, primary key value and the column name. – Rule 3: Systematic treatment of NULL values • NULL values are supported in fully relational DBMS for to represent missing information and inapplicable information in a systematic way independent of data type. 16 March 2021 24
  • 25. contd.. – Rule 4: Database description rule • The database description is represented at the logical level in the same way as ordinary data, so that authorized users can apply the same relational language to its interrogation as they apply to the regular data. • This means, the RDBMS must have a data dictionary. • Rule 5: Comprehensive data sub-language – The RDBMS should have its own extension of SQL. – The SQL should support Data Definition, View Definition, Data Manipulation, Integrity Constraint, and Authorization. • Rule 6: Views updation – All views that are theoretically updatable are also updatable by the system. Similarly, the views which are theoretically non- updatable are also non-updatable by the database system. 16 March 2021 25
  • 26. contd.. • Rule 7: High-level update, insert, deletes – A RDBMS should not only support retrieval of data as relational sets, but also insertion, updation and deletion of data as a relational set. • Rule 8: Physical data independence – Application programs and terminal activities are not disturbed if any changes are made either to storage representations or access methods. • Rule 9: Logical data independence – User programs and the user should not be aware of any changes to the structure of the tables such as the addition of extra columns. 16 March 2021 26
  • 27. contd.. • Rule 10: Distribution independence – RDBMS has distribution independence. The RDBMS may spread across more than one system and across several networks. However to the end-user, the tables should appear no different to those that are local. • Rule 11: Integrity Rules – Integrity rules must be supported by the database and the constraints must be stored within the catalogue, separate from the application. • Rule 12: Data integrity cannot be subverted – If a relational system has a low-level language, that low level cannot be used to subvert or bypass the integrity rules. 16 March 2021 27
  • 28. Relational Database and its Schema • Relational database consists of multiple relations or tables. • The information about an enterprise is broken up into parts, with each relation storing one part of the information. • A relational schema contains the name of the relation and name of all columns or attributes. • For the complete database, it is known as relational database schema that is actually a collection of different schemas that refers to different relations or tables available in the database. 16 March 2021 28
  • 29. contd.. • For example: A UNIVERSITY database can have a relational database schema as below: – student(ID, name, dept_name, tot_cred) – advisor(s_id,i_id) – teaches(ID, course_ID, sec_ID, semester, year) – takes(ID, course_ID,sec_ID,semester, year, grade) – section(course_ID, sec_ID, semester, year, building, room_no, time_slot_id) – timeslot(time_slot_id, day, start_time, end_time) – prereq(course_ID, prereq_ID) – classroom(building, room_number,capacity) – department(dept_name, building, budget) – instructor(ID, name, dept_name, salary) – course(course_ID, title,dept_name,credits) 16 March 2021 29
  • 31. Conversion of ER Diagram to Relational Schema • A database that conforms to an ER diagram can be represented by a collection of relational schemas. • Both, the ER model and Relational data model are abstract i.e. logical representations of real-world enterprises. • Converting Strong entity types  Each entity type becomes a table  Each single-valued attribute becomes a column  Derived attributes are ignored  Composite attributes are represented by components  Multi-valued attributes are represented by a separate table  The key attribute of the entity type becomes the primary key of the table 16 March 2021 31
  • 32. Converting Entity Types 16 March 2021 32
  • 33. Converting weak entity types 16 March 2021 33
  • 34. Converting Relationships • The way relationships are represented depends on the cardinality and the degree of the relationship. • The possible cardinalities are: 1:1, 1:N, N:1, M:N • The degrees are: Unary Binary Ternary … 16 March 2021 34
  • 37. Binary 1:N / N:1 16 March 2021 37
  • 43. Case Study: Company Database • Problem Statement: The COMPANY database problem has been discussed in Ch-3: Data Modeling using ER Model. • The ER details of the Company Database is as below: – EMPLOYEE (Entity Type) • Attribute: Emp_name, Emp_ID, SSN, age, address, gender, salary, DOB, and supervisor – DEPARTMENT (Entity Type) • Attribute: Name, Number, Location, Manager, and Manager_start_date – PROJECT (Entity Type) • Attribute: Name, Number, Location, Controlling_dept – DEPENDENT (Entity Type) • Attribute: Name, gender, DOB, Employee, Relationship 16 March 2021 43
  • 44. contd.. – MANAGES: • Binary and 1:1 Cardinality • Entity types: EMPLOYEE and DEPARTMENT • Participation: EMPLOYEE (Partial); DEPARTMENT (Total) – WORKS_FOR: • Binary and N:1 Cardinality • Entity types: EMPLOYEE and DEPARTMENT – CONTROLS: • Binary and 1:N Cardinality • Entity types: DEPARTMENT and PROJECT 16 March 2021 44
  • 45. contd.. – SUPERVISION: • Unary and 1:N Cardinality • Entity types: EMPLOYEE – WORKS_ON: • Binary and M:N Cardinality • Entity types: EMPLOYEE and PROJECT – DEPENDENTS_OF: • Binary and 1:N Cardinality • Entity types: EMPLOYEE and DEPENDENT 16 March 2021 45
  • 46. Case Study: Relational Schema • Employee(Emp_name, Emp_ID, SSN, address, gender, salary, DOB, supervisor, Dept_ID) • Department(Name, Dept_ID, Location, Manager, and Manager_start_date) • Project(Name, Proj_ID, Location, Controlling_dept) • Dependent(Name, gender, DOB, Relationship, Emp_ID) • Works_On(Emp_ID, Proj_ID, no_of_hrs, supervisor) Note: Attributes in “Red” are the FOREIGN KEY in that table 16 March 2021 46
  • 48. Representation of Generalization/Specialization • In case of generalization/specialization-related ER diagram, one schema will be constructed for the generalized entity set and the schemas for each of the specialized entity sets • Person = (person_id, name, address) • Employee = (emp_id, salary) • Customer = (cust_id, credit_rating) 16 March 2021 48
  • 49. contd.. • When the generalization/specialization is a disjointness case, the schemas are constructed only for the specialized entity sets – Employee = (employee_id, name, address, salary) – Customer = (customer_id, name, address, credit_rating) • Representation of Aggregation – To represent aggregation, create a schema containing the primary key of the aggregated relationship, primary key of the associated entity set and descriptive attributes (if any) 16 March 2021 49
  • 50. contd.. •Employee = (eid, name, address) •Branch = (bid, bname, asset) •Job = (jobid, position, responsibility) • Works_on = (eid, bid, jobid) • Manager = (mid, mgrname) • Manages = (eid, bid, jobid, mid) 16 March 2021 50