DBDA
(Database Design and Applications)
CH4-5
By: Prof. Ganesh Ingle
Session objective
Quick look of previous Session
Database Design Process
ER Modeling concepts
EER Concepts and notations
Textbook Reference Book(s) & other resources
T1 Ramez Elmasri & Shamkant B. Navathe, Fundamentals of
Database Systems, Pearson Education, 5th Edition, 2007
Reference Book(s) & other resources
R1 Abraham Silberschatz, Henry F Korth and S Sudarshan,
Database System Concepts, McGraw Hill, 6th Ed., 2013
Text Book
Types of DBMS languages
 Data Definition Language (DDL) allows the DBA or user
to describe and name entities, attributes, and relationships
required for the application plus any associated integrity
and security constraints
 Data Manipulation Language (DML) provides basic data
manipulation operations on data held in the database
 Data Control Language (DCL) defines activities that are
not in the categories of those for the DDL and DML, such
as granting privileges to users, and defining when proposed
changes to a databases should be irrevocably made
Database Languages
Types of DBMS languages
DATA Association(ER Model)
Entity:
• A thing or object in real world that is distinguishable from other
objects
Eg: Employee in an organization
• An entity has set of properties and values for he same set of
properties that many uniquely identify an entity
Eg: Employee (EmpIdNo,Mobile no etc)
• An entity set is a set of entities of the same type that share their
same properties or attributes
Eg. Bank (employee(empid),customer(acc number))
DATA Association(ER Model)
Entity:
• A thing or object in real world that is distinguishable from other
objects
Eg: Employee in an organization
• An entity has set of properties and values for he same set of
properties that many uniquely identify an entity
Eg: Employee (EmpIdNo,Mobile no etc)
• An entity set is a set of entities of the same type that share their
same properties or attributes
Eg. Bank (employee(empid),customer(acc number))
DATA Association(ER Model)
Attributes:
• Descriptive properties possessed by each member of an entity set.
• For each attribute ,there is a set of permitted values called domain
• Student(entity)
• Attributes(std_id,std_nme,std_add,std_class)
DATA Association(ER Model)
Attributes
Simple/Composite Sinlge/Muti valued
Derived
Simple :are not
divided in sub parts
eg: unique-id(123456
canot be divided into
12 and 345)
Composite: can be
divided into subparts
Eg: name (first and
last,middle)
single :single value
Eg: order-id
Multi: multiple
values
Eg: multiple phone
numbers
Derived :derived
from otger related
attributes
Eg: age (from name
and DOB)
Age=current_date-DOB
DATA Association(ER Model)
Strong and weak entity set
Strong entity Weak entity
Has a primary key Does not have sufficient attributes to form
primary key
Primary key Primary key???
Entity=set payment :
Attribute:
1. Payment_Number
2. Payment_Date
3. Payment_Amount
Eg. EMI to pay for number of users
How to form PK from weak entity set
How to from the primary key of a weak
entity set ?
You have to use PK of SE on which weak
entity is dependant plus the WE set
discriminator.
Eg. Same loan pay banking domain table
design and relation to be shown
PK,FK,discriminator
Relationship Sets
Relationship Sets-
• A relationship is an association among entities.
• Relationship set is a set of relationship of the
same type.
Eg.
Customer =c1,c2,c3,…..cn
Loan= L1,L2,L3……Ln respectively
Connectivity / Cardinality/Relationships
• It describes the mapping of associated instances
in the relationships
OR
• It expresses the number of entities to which an
entity can be associated via a relationship set
Mapping cardinalities
One to one One to many Many to one Many to Many
• One to one:Department and head(company,university)
• One to many :Hod(1,2,3) faculty(1,2,3)single hod can represent
many faculty likewise one team leader represent many emp
• Many to one:relation of course to faculty many courses are being
taught by one faculty .
• Many to many : projrct 1 to n emp 1 to n
OR
• It expresses the number of entities to which an entity can be
associated via a relationship set
Mapping(Connectivity / Cardinality/Relationships)
Mapping(Connectivity / Cardinality/Relationships)
Mapping(Connectivity / Cardinality/Relationships)
 How an entity participate in a relationship???
 Total: If every entity in E participates in t=atleast one
relationship in R
Eg. Student elective subjects at least register for a course.
 Partial: Some entities in E participates in in
relationship R
Eg. Student and CR relation( not all the students are
participated for being CR)
Participation constraint
 A key allows to identify a set of attributes to
distinguish entities from each other.
 Types of key:
 Superkey: Set of one or more attributes that allows
to identify an entity uniquely.(It may contain extra
attributes)eg. {Std_Id,Std_Name}
 Candidate key: It is minimal set of super key which
can uniquely identify an entity. eg. {Std_Id} not id
and name both.
 New definition: SK for which no subset is a superkey.
Key in Relation
Key in Relation
 Note : More than one CK is possible in relation
 Suppose we have 5 CK
 Primary key: vvimp
Chosen by DBA very important to identify the entity and the record. Eg.???
 Alternate Key/s:
CK-PK=AK ,5-1=4 . All 4 can become PK but not chosen by DBA.
 Secondary Key:
 Used for data retrieval. Eg.Emp_id(PK) ,Dept(Secondary key)
I want to find the employee wrt to dept then Dept is secondary key.
Many time in a Group by clause we use Secondary key.
 Foreign Key: PK of one related to another entity id FK
 Composite Key: Combination of two or more columns in a table that
uniquely identify the tuple/record/row.
Eg.CutomerId,OrderID,SalesDetail
THANK YOU

DBMS CS 4-5

  • 1.
    DBDA (Database Design andApplications) CH4-5 By: Prof. Ganesh Ingle
  • 2.
    Session objective Quick lookof previous Session Database Design Process ER Modeling concepts EER Concepts and notations
  • 3.
    Textbook Reference Book(s)& other resources T1 Ramez Elmasri & Shamkant B. Navathe, Fundamentals of Database Systems, Pearson Education, 5th Edition, 2007 Reference Book(s) & other resources R1 Abraham Silberschatz, Henry F Korth and S Sudarshan, Database System Concepts, McGraw Hill, 6th Ed., 2013 Text Book
  • 4.
    Types of DBMSlanguages
  • 5.
     Data DefinitionLanguage (DDL) allows the DBA or user to describe and name entities, attributes, and relationships required for the application plus any associated integrity and security constraints  Data Manipulation Language (DML) provides basic data manipulation operations on data held in the database  Data Control Language (DCL) defines activities that are not in the categories of those for the DDL and DML, such as granting privileges to users, and defining when proposed changes to a databases should be irrevocably made Database Languages
  • 6.
    Types of DBMSlanguages
  • 7.
    DATA Association(ER Model) Entity: •A thing or object in real world that is distinguishable from other objects Eg: Employee in an organization • An entity has set of properties and values for he same set of properties that many uniquely identify an entity Eg: Employee (EmpIdNo,Mobile no etc) • An entity set is a set of entities of the same type that share their same properties or attributes Eg. Bank (employee(empid),customer(acc number))
  • 8.
    DATA Association(ER Model) Entity: •A thing or object in real world that is distinguishable from other objects Eg: Employee in an organization • An entity has set of properties and values for he same set of properties that many uniquely identify an entity Eg: Employee (EmpIdNo,Mobile no etc) • An entity set is a set of entities of the same type that share their same properties or attributes Eg. Bank (employee(empid),customer(acc number))
  • 9.
    DATA Association(ER Model) Attributes: •Descriptive properties possessed by each member of an entity set. • For each attribute ,there is a set of permitted values called domain • Student(entity) • Attributes(std_id,std_nme,std_add,std_class)
  • 10.
    DATA Association(ER Model) Attributes Simple/CompositeSinlge/Muti valued Derived Simple :are not divided in sub parts eg: unique-id(123456 canot be divided into 12 and 345) Composite: can be divided into subparts Eg: name (first and last,middle) single :single value Eg: order-id Multi: multiple values Eg: multiple phone numbers Derived :derived from otger related attributes Eg: age (from name and DOB) Age=current_date-DOB
  • 11.
  • 12.
    Strong and weakentity set Strong entity Weak entity Has a primary key Does not have sufficient attributes to form primary key Primary key Primary key??? Entity=set payment : Attribute: 1. Payment_Number 2. Payment_Date 3. Payment_Amount Eg. EMI to pay for number of users
  • 13.
    How to formPK from weak entity set How to from the primary key of a weak entity set ? You have to use PK of SE on which weak entity is dependant plus the WE set discriminator. Eg. Same loan pay banking domain table design and relation to be shown PK,FK,discriminator
  • 14.
    Relationship Sets Relationship Sets- •A relationship is an association among entities. • Relationship set is a set of relationship of the same type. Eg. Customer =c1,c2,c3,…..cn Loan= L1,L2,L3……Ln respectively Connectivity / Cardinality/Relationships • It describes the mapping of associated instances in the relationships OR • It expresses the number of entities to which an entity can be associated via a relationship set
  • 15.
    Mapping cardinalities One toone One to many Many to one Many to Many • One to one:Department and head(company,university) • One to many :Hod(1,2,3) faculty(1,2,3)single hod can represent many faculty likewise one team leader represent many emp • Many to one:relation of course to faculty many courses are being taught by one faculty . • Many to many : projrct 1 to n emp 1 to n OR • It expresses the number of entities to which an entity can be associated via a relationship set Mapping(Connectivity / Cardinality/Relationships)
  • 16.
  • 17.
  • 18.
     How anentity participate in a relationship???  Total: If every entity in E participates in t=atleast one relationship in R Eg. Student elective subjects at least register for a course.  Partial: Some entities in E participates in in relationship R Eg. Student and CR relation( not all the students are participated for being CR) Participation constraint
  • 19.
     A keyallows to identify a set of attributes to distinguish entities from each other.  Types of key:  Superkey: Set of one or more attributes that allows to identify an entity uniquely.(It may contain extra attributes)eg. {Std_Id,Std_Name}  Candidate key: It is minimal set of super key which can uniquely identify an entity. eg. {Std_Id} not id and name both.  New definition: SK for which no subset is a superkey. Key in Relation
  • 20.
    Key in Relation Note : More than one CK is possible in relation  Suppose we have 5 CK  Primary key: vvimp Chosen by DBA very important to identify the entity and the record. Eg.???  Alternate Key/s: CK-PK=AK ,5-1=4 . All 4 can become PK but not chosen by DBA.  Secondary Key:  Used for data retrieval. Eg.Emp_id(PK) ,Dept(Secondary key) I want to find the employee wrt to dept then Dept is secondary key. Many time in a Group by clause we use Secondary key.  Foreign Key: PK of one related to another entity id FK  Composite Key: Combination of two or more columns in a table that uniquely identify the tuple/record/row. Eg.CutomerId,OrderID,SalesDetail
  • 21.