Module-2 - Data Modeling
Module-2 - Data Modeling
BCSE302L – DBMS
Module 2 Data Modeling
Dr. K.P. Vijayakumar,
VIT Chennai
COURSE
Co_Name Co_Id Co_Dept
Entity
STUDENT
An object or a thing in the real word represents an
Name RegNo Major entity
Ram 22BCE1001 CSE An entity may be an object with a physical existence
John 22BCE1002 MECH Example : person, car, house, employee, student
Entities- Students, courses
COURSE
Co_Name Co_Code Co_Dept
Entity Type
A collection entities that have same attributes, but
Database CS1078 CSE
each entity has its own value(s) for each attribute
Robotics MH073 MECH Entity Set
The collection of all entities of a particular entity
type in the database at any point in time
Attributes
Each entity has attributes—the particular
properties that describe it
Employee Entity
Name, Id, Address, age, designation , salary
Types of Attributes
Simple and Composite
Single valued and multivalued
Stored and Derived
NULL values
Several meaning for Null values
Not applicable value
Example : Apartment No, Degree
Value Unknown
Value exists but is not available
Complex Attributes
composite and multivalued attributes can be nested arbitrarily
Composite - ()
Phone(Area_code, Phone_number)
Address(Street_address (Number, Street, Apartment_no), City, State, Zip)
Multivalued - {}
{ Phone(Area_code,Phone_number) }
Example
Address_phone
Address_phone( Address(Street_address (Number, Street, Apartment_no), City, State,
Zip), {Phone(Area_code,Phone_number)})
Dr. K.P. Vijayakumar, VIT Chennai, India.
Relationship 15
Ternary
Dr. K.P. Vijayakumar, VIT Chennai, India.
Source: Ramez Elmasri and Shamkant B. Navathe
Mapping Cardinalities 17
A B
Mapping cardinalities or cardinality ratios
express the number of entities to which
another entity can be associated via a
relationship set
useful in describing binary relationship sets
One to one
One to many
Many to one
Many to Many
c. Many-to-one. An entity in A is
associated with at most one entity in B.
An entity in B, however, can be
associated with any number (zero or
more) of entities in A.
d. Many-to-many. An entity in A is
associated with any number (zero or
Many-to-one Many-to-many more) of entities in B, and an entity in B
is associated with any number (zero or
more) of entities in A.
DBMS BCSE302L
Foreign Key − An attribute to link two entity
Ram 22bcse1001 CSE
John 22bcse1002 CSE IWP CSE3002
sets through the primary key.
OS CSE2005
Diagram
Employee
Employee ={Eid, Name,Designation}
Department
Department={DID,Name, EID}
Last AccessDate
BANK database
Specialization and
Generalization
Relation/
Relational Data Model
columns
Table Database is a collection of relations
A1 A2 A3
A Relational model groups data into one or more tables.
t1
rows The data is represented in the form of rows and columns i.e.
t2
tables.
Domain
Set of atomic values
Relation Schema
STUDENT R, denoted by R(A1, A2, ...,An)
Name Stu_ID Major
Student(Name,Stud_ID,Major)
Jack CD0748 CSE
Relation/ Relation State
John CD0468 MECH
r of the relation schema R(A1, A2, ..., An), also denoted
by r(R), is a set of n-tuples r = {t1, t2, ..., tm}.
Name Stu-ID Major Cname Ccode Key is an attribute or collection of attributes that
Ram 22bcse1001 CSE DBMS BCSE302L uniquely identifies an entity among entity set.
John 22bcse1002 CSE IWP CSE3002 For example, the roll_number of a student makes
him/her identifiable among students.
Ram 22bcse1001 CSE OS CSE2005
Super Key − A set of attributes (one or more)
Super Key – {Stu-ID,CCode} that collectively identifies a tuple or row in the
Candidate Key – {Stu-ID}, {CCode} relation schema.
Primary Key – {Stu-ID}, {Ccode} Candidate Key − A minimal super key is called a
candidate key. i.e, a relation schema may have
more than one key. In this case, each of the keys
Stud Course is called a candidate key.
Name Stu-ID Major Cname Ccode
Primary Key − A primary key is one of the
Ram 22bcse1001 CSE DBMS BCSE302L candidate keys chosen to uniquely identify a
John 22bcse1002 CSE IWP CSE3002 tuple or row in the relation schema.
OS CSE2005
Dr. K.P. Vijayakumar, VIT Chennai, India.
Source: Ramez Elmasri and Shamkant B. Navathe
Stud Course Keys 43
DBMS BCSE302L
Foreign Key − An attribute to link two
Ram 22bcse1001 CSE
John 22bcse1002 CSE IWP CSE3002
relation schemas through the primary key.
OS CSE2005
Primary Key
Foreign Key
Foreign Key
Refers
Foreign Key
Foreign Key
Foreign Key
Foreign Key
Multivalued Attributes
Employee
ISA
END OF MODULE - 2