DBMS-Wee3 - Lecture Material
DBMS-Wee3 - Lecture Material
DBMS-Wee3 - Lecture Material
Jan-Apr, 2018
ppd@cse.iitkgp.ernet.in
Srijoni Majumdar
Himadri B G S Bhuyan
Gurunath Reddy M
Week 02 Recap
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Database System Concepts - 6th Edition 11.2 ©Silberschatz, Korth and Sudarshan
PPD
Module Objectives
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Database System Concepts - 6th Edition 11.3 ©Silberschatz, Korth and Sudarshan
PPD
Module Outline
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Database System Concepts - 6th Edition 11.4 ©Silberschatz, Korth and Sudarshan
PPD
Constructs
Triggers
Database System Concepts - 6th Edition 11.5 ©Silberschatz, Korth and Sudarshan
PPD
Connection Query
Library Processor
Database System Concepts - 6th Edition 11.6 ©Silberschatz, Korth and Sudarshan
Accessing SQL From a Programming Language
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Database System Concepts - 6th Edition 11.7 ©Silberschatz, Korth and Sudarshan
JDBC
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Database System Concepts - 6th Edition 11.8 ©Silberschatz, Korth and Sudarshan
ODBC
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Database System Concepts - 6th Edition 11.9 ©Silberschatz, Korth and Sudarshan
PPD
Source: https://dzone.com/articles/tutorial-connecting-to-odbc-data-sources-with-pyth
Database System Concepts - 6th Edition 11.10 ©Silberschatz, Korth and Sudarshan
PPD
C Program
Functions
Variables
SQL Query
Table Names Datadase
Attributes Schema
Tables
Query
Processor
Database System Concepts - 6th Edition 11.11 ©Silberschatz, Korth and Sudarshan
Embedded SQL
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Database System Concepts - 6th Edition 11.12 ©Silberschatz, Korth and Sudarshan
Embedded SQL (Cont.)
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Before executing any SQL statements, the program must first connect
to the database. This is done using:
EXEC-SQL connect to server user user-name using password;
Here, server identifies the server to which a connection is to be
established
Variables of the host language can be used within embedded SQL
statements. They are preceded by a colon (:) to distinguish from
SQL variables (e.g., :credit_amount )
Variables used as above must be declared within DECLARE section,
as illustrated below. The syntax for declaring the variables, however,
follows the usual host language syntax
EXEC-SQL BEGIN DECLARE SECTION
int credit-amount ;
EXEC-SQL END DECLARE SECTION;
Database System Concepts - 6th Edition 11.13 ©Silberschatz, Korth and Sudarshan
Embedded SQL (Cont.)
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Database System Concepts - 6th Edition 11.14 ©Silberschatz, Korth and Sudarshan
Embedded SQL (Cont.)
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Example:
From within a host language, find the ID and name of
students who have completed more than the number of
credits stored in variable credit_amount in the host langue
Specify the query in SQL as follows:
EXEC SQL
declare c cursor for
select ID, name
from student
where tot_cred > :credit_amount
END_EXEC
The variable c (used in the cursor declaration) is used to
identify the query
Database System Concepts - 6th Edition 11.15 ©Silberschatz, Korth and Sudarshan
Embedded SQL (Cont.)
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Database System Concepts - 6th Edition 11.16 ©Silberschatz, Korth and Sudarshan
Embedded SQL (Cont.)
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Database System Concepts - 6th Edition 11.17 ©Silberschatz, Korth and Sudarshan
PPD
The program prompts the user for an order number, retrieves the
customer number, salesperson, and status of the order, and displays
the retrieved information on the screen
Database System Concepts - 6th Edition 11.18 ©Silberschatz, Korth and Sudarshan
Updates Through Embedded SQL
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Database System Concepts - 6th Edition 11.19 ©Silberschatz, Korth and Sudarshan
PPD
Constructs
Triggers
Database System Concepts - 6th Edition 11.20 ©Silberschatz, Korth and Sudarshan
PPD
C Program
Functions, Variables
SQL Query
Table Names
Attributes Datadase
Function Schema
Procedure Tables
QP
Database System Concepts - 6th Edition 11.21 ©Silberschatz, Korth and Sudarshan
Functions and Procedures
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Database System Concepts - 6th Edition 11.22 ©Silberschatz, Korth and Sudarshan
SQL Functions
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Database System Concepts - 6th Edition 11.23 ©Silberschatz, Korth and Sudarshan
SQL functions (Cont.)
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Database System Concepts - 6th Edition 11.24 ©Silberschatz, Korth and Sudarshan
Table Functions
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Database System Concepts - 6th Edition 11.25 ©Silberschatz, Korth and Sudarshan
SQL Procedures
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
SQL supports constructs that gives it almost all the power of a general-
purpose programming language.
Warning: most database systems implement their own variant of the
standard syntax below.
Compound statement: begin … end,
May contain multiple SQL statements between begin and end.
Local variables can be declared within a compound statements
While and repeat statements:
while boolean expression do
sequence of statements ;
end while
repeat
sequence of statements ;
until boolean expression
end repeat
Database System Concepts - 6th Edition 11.27 ©Silberschatz, Korth and Sudarshan
Language Constructs (Cont.)
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
For loop
Permits iteration over all results of a query
Database System Concepts - 6th Edition 11.28 ©Silberschatz, Korth and Sudarshan
Language Constructs (Cont.)
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Database System Concepts - 6th Edition 11.29 ©Silberschatz, Korth and Sudarshan
External Language Routines*
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Database System Concepts - 6th Edition 11.30 ©Silberschatz, Korth and Sudarshan
External Language Routines (Contd.)*
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Database System Concepts - 6th Edition 11.31 ©Silberschatz, Korth and Sudarshan
External Language Routines (Cont.)*
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Database System Concepts - 6th Edition 11.32 ©Silberschatz, Korth and Sudarshan
Security with External Language Routines*
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Database System Concepts - 6th Edition 11.33 ©Silberschatz, Korth and Sudarshan
PPD
Constructs
Triggers
TRIGGERS
Database System Concepts - 6th Edition 11.34 ©Silberschatz, Korth and Sudarshan
Triggers
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Database System Concepts - 6th Edition 11.35 ©Silberschatz, Korth and Sudarshan
Triggering Events and Actions in SQL
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Database System Concepts - 6th Edition 11.36 ©Silberschatz, Korth and Sudarshan
Trigger to Maintain credits_earned value
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Database System Concepts - 6th Edition 11.37 ©Silberschatz, Korth and Sudarshan
Statement Level Triggers
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Database System Concepts - 6th Edition 11.38 ©Silberschatz, Korth and Sudarshan
When Not To Use Triggers
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Database System Concepts - 6th Edition 11.39 ©Silberschatz, Korth and Sudarshan
When Not To Use Triggers (Cont.)
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Database System Concepts - 6th Edition 11.40 ©Silberschatz, Korth and Sudarshan
Module Summary
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Database System Concepts - 6th Edition 11.41 ©Silberschatz, Korth and Sudarshan
PPD
Database System Concepts - 6th Edition 11.42 ©Silberschatz, Korth and Sudarshan
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
ppd@cse.iitkgp.ernet.in
Srijoni Majumdar
Himadri B G S Bhuyan
Gurunath Reddy M
Module Recap
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Database System Concepts - 6th Edition 12.2 ©Silberschatz, Korth and Sudarshan
PPD
Module Objectives
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Database System Concepts - 6th Edition 12.3 ©Silberschatz, Korth and Sudarshan
PPD
Module Outline
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Relational Algebra
Tuple Relational Calculus (Overview only)
Domain Relational Calculus (Overview only)
Equivalence of Algebra and Calculus
Database System Concepts - 6th Edition 12.4 ©Silberschatz, Korth and Sudarshan
Formal Relational Query Language
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Relational Algebra
Procedural and Algebra based
Tuple Relational Calculus
Non-Procedural and Predicate Calculus based
Domain Relational Calculus
Non-Procedural and Predicate Calculus based
Database System Concepts - 6th Edition 12.5 ©Silberschatz, Korth and Sudarshan
PPD
Relational Algebra
Tuple Relational
Calculus
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Domain Relational
Calculus
Equivalence of Algebra
and Calculus
RELATIONAL ALGEBRA
Database System Concepts - 6th Edition 12.6 ©Silberschatz, Korth and Sudarshan
PPD
Relational Algebra
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
select:
project:
union:
set difference: –
Cartesian product: x
rename:
The operators take one or two relations as inputs and produce a new
relation as a result
Database System Concepts - 6th Edition 12.7 ©Silberschatz, Korth and Sudarshan
PPD
Select Operation
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Notation: p(r)
p is called the selection predicate
Defined as:
Example of selection:
dept_name=“Physics”(instructor)
A=B ^ D > 5 (r)
Database System Concepts - 6th Edition 12.8 ©Silberschatz, Korth and Sudarshan
PPD
Project Operation
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Notation:
A1 , A2 ,, Ak (r )
where A1, A2 are attribute names and r is a relation name
The result is defined as the relation of k columns obtained by erasing
the columns that are not listed
Duplicate rows removed from result, since relations are sets
Example: To eliminate the dept_name attribute of instructor
A,C (r)
Database System Concepts - 6th Edition 12.9 ©Silberschatz, Korth and Sudarshan
PPD
Union Operation
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Notation: r s
Defined as:
r s = {t | t r or t s}
For r s to be valid.
1. r, s must have the same arity (same number of attributes)
2. The attribute domains must be compatible (example: 2nd column
of r deals with the same type of values as does the 2nd
column of s)
Example: to find all courses taught in the Fall 2009 semester, or in the
Spring 2010 semester, or in both
Database System Concepts - 6th Edition 12.10 ©Silberschatz, Korth and Sudarshan
PPD
Notation r – s
Defined as:
r – s = {t | t r and t s}
Database System Concepts - 6th Edition 12.11 ©Silberschatz, Korth and Sudarshan
Set-Intersection Operation
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Notation: r s
Defined as:
r s = { t | t r and t s }
Assume:
r, s have the same arity
attributes of r and s are compatible
Note: r s = r – (r – s)
rs
Database System Concepts - 6th Edition 12.12 ©Silberschatz, Korth and Sudarshan
PPD
Cartesian-Product Operation
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Notation r x s
Defined as:
r x s = {t q | t r and q s}
rxs
Database System Concepts - 6th Edition 12.13 ©Silberschatz, Korth and Sudarshan
Rename Operation
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
x ( A1 , A 2 ,..., A n ) ( E )
returns the result of expression E under the name X, and with the
attributes renamed to A1 , A2 , …., An .
Database System Concepts - 6th Edition 12.14 ©Silberschatz, Korth and Sudarshan
PPD
Division Operation
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Database System Concepts - 6th Edition 12.15 ©Silberschatz, Korth and Sudarshan
PPD
Relations r, s:
A B B
1 1
2
3 2
1 s
1
1
3
4
6 e.g.
1
A is customer name
2
r s: A r
B is branch-name
1 and 2 here show two specific branch-names
(Find customers who have an account in all branches of the
bank)
Source: db.fcngroup.nl/silberslides/Divsion%20-%20Slides%20-%20relational%20algebra.pptx
Database System Concepts - 6th Edition 12.16 ©Silberschatz, Korth and Sudarshan
Another Division Example
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Relations r, s:
A B C D E D E
a a 1 a 1
a a 1 b 1
a b 1 s
a a 1
a b 3
a a 1
a b 1
a b 1
r
e.g.
r s: Students who have taken both "a” and
A B C “b” courses, with instructor “1”
Source: db.fcngroup.nl/silberslides/Divsion%20-%20Slides%20-%20relational%20algebra.pptx
Database System Concepts - 6th Edition 12.17 ©Silberschatz, Korth and Sudarshan
Formal Definition
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
E1 E2
E1 – E2
E1 x E2
Database System Concepts - 6th Edition 12.18 ©Silberschatz, Korth and Sudarshan
PPD
Relational Algebra
Tuple Relational
Calculus
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Domain Relational
Calculus
Equivalence of Algebra
and Calculus
Database System Concepts - 6th Edition 12.19 ©Silberschatz, Korth and Sudarshan
Tuple Relational Calculus
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Database System Concepts - 6th Edition 12.20 ©Silberschatz, Korth and Sudarshan
Predicate Calculus Formula
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Database System Concepts - 6th Edition 12.21 ©Silberschatz, Korth and Sudarshan
Safety of Expressions
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Database System Concepts - 6th Edition 12.22 ©Silberschatz, Korth and Sudarshan
PPD
Relational Algebra
Tuple Relational
Calculus
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Domain Relational
Calculus
Equivalence of Algebra
and Calculus
Database System Concepts - 6th Edition 12.23 ©Silberschatz, Korth and Sudarshan
Domain Relational Calculus
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Database System Concepts - 6th Edition 12.24 ©Silberschatz, Korth and Sudarshan
PPD
Relational Algebra
Tuple Relational
Calculus
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Domain Relational
Calculus
Equivalence of Algebra
and Calculus
Database System Concepts - 6th Edition 12.25 ©Silberschatz, Korth and Sudarshan
PPD
Source: http://www.cs.sfu.ca/CourseCentral/354/louie/Equiv_Notations.pdf
Database System Concepts - 6th Edition 12.26 ©Silberschatz, Korth and Sudarshan
PPD
Source: http://www.cs.sfu.ca/CourseCentral/354/louie/Equiv_Notations.pdf
Database System Concepts - 6th Edition 12.27 ©Silberschatz, Korth and Sudarshan
PPD
Source: http://www.cs.sfu.ca/CourseCentral/354/louie/Equiv_Notations.pdf
Database System Concepts - 6th Edition 12.28 ©Silberschatz, Korth and Sudarshan
PPD
Source: http://www.cs.sfu.ca/CourseCentral/354/louie/Equiv_Notations.pdf
Database System Concepts - 6th Edition 12.29 ©Silberschatz, Korth and Sudarshan
PPD
Source: http://www.cs.sfu.ca/CourseCentral/354/louie/Equiv_Notations.pdf
Database System Concepts - 6th Edition 12.30 ©Silberschatz, Korth and Sudarshan
PPD
Source: http://www.cs.sfu.ca/CourseCentral/354/louie/Equiv_Notations.pdf
Database System Concepts - 6th Edition 12.31 ©Silberschatz, Korth and Sudarshan
PPD
Source: http://www.cs.sfu.ca/CourseCentral/354/louie/Equiv_Notations.pdf
Database System Concepts - 6th Edition 12.32 ©Silberschatz, Korth and Sudarshan
PPD
Source: http://www.cs.sfu.ca/CourseCentral/354/louie/Equiv_Notations.pdf
Database System Concepts - 6th Edition 12.33 ©Silberschatz, Korth and Sudarshan
PPD
Source: http://www.cs.sfu.ca/CourseCentral/354/louie/Equiv_Notations.pdf
Database System Concepts - 6th Edition 12.34 ©Silberschatz, Korth and Sudarshan
Module Summary
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Database System Concepts - 6th Edition 12.35 ©Silberschatz, Korth and Sudarshan
PPD
Database System Concepts - 6th Edition 12.36 ©Silberschatz, Korth and Sudarshan
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
ppd@cse.iitkgp.ernet.in
Srijoni Majumdar
Himadri B G S Bhuyan
Gurunath Reddy M
Module Recap
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Relational Algebra
Tuple Relational Calculus (Overview only)
Domain Relational Calculus (Overview only)
Equivalence of Algebra and Calculus
Module Objectives
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Module Outline
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Design Process
E-R Model
Entity and Entity Set
Relationship
Cardinality
Attributes
Weak Entity Sets
Design Process
E-R Model
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
DESIGN PROCESS
Design Process
E-R Model
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
E-R MODEL
Binary relationship
involve two entity sets (or degree two).
most relationship sets in a database system are binary.
Relationships between more than two entity sets are rare. Most
relationships are binary. (More on this later.)
Example: students work on research projects under the
guidance of an instructor.
relationship proj_guide is a ternary relationship between
instructor, student, and project
Attribute types:
Simple and composite attributes.
Single-valued and multivalued attributes
Example: multivalued attribute: phone_numbers
Derived attributes
Can be computed from other attributes
Example: age, given date_of_birth
Domain – the set of permitted values for each attribute
ppd@cse.iitkgp.ernet.in
Srijoni Majumdar
Himadri B G S Bhuyan
Gurunath Reddy M
Module Recap
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Design Process
E-R Model
Entity and Entity Set
Relationship
Cardinality
Attributes
Weak Entity Sets
Module Objectives
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Module Outline
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
E-R Diagram
E-R Model to Relational Schema
E-R Diagram
E-R Model to Relational
Schema
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
E-R DIAGRAM
E-R Diagram
E-R Model to Relational
Schema
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
A weak entity set becomes a table that includes a column for the
primary key of the identifying strong entity set
section ( course_id, sec_id, sem, year )
ppd@cse.iitkgp.ernet.in
Srijoni Majumdar
Himadri B G S Bhuyan
Gurunath Reddy M
Module Recap
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
E-R Diagram
E-R Model to Relational Schema
Module Objectives
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Module Outline
SWAYAM: NPTEL-NOC MOOCs Instructor: Prof. P P Das, IIT Kharagpur. Jan-Apr, 2018
Method 1:
Form a schema for the higher-level entity
Form a schema for each lower-level entity set, include primary
key of higher-level entity set and local attributes
schema attributes
person ID, name, street, city
student ID, tot_cred
employee ID, salary
Method 2:
Form a schema for each entity set with all local and inherited
attributes
schema attributes
person ID, name, street, city
student ID, name, street, city, tot_cred
employee ID, name, street, city, salary
DESIGN ISSUES
Chen, IDE1FX, …