Data Modeling.1
-
Upload
suyashi-purwar -
Category
Documents
-
view
221 -
download
0
Transcript of Data Modeling.1
-
8/13/2019 Data Modeling.1
1/35
Conceptual Data Modeling
Using E-R Diagrams
-
8/13/2019 Data Modeling.1
2/35
5-Sep-11 Data Modeling Using E-R Diagrams 2
What is data model ?
You have seen some data models.
Company Schema (in relational model)
Some example of ER diagram
Depicts structure of database.
-
8/13/2019 Data Modeling.1
3/35
5-Sep-11 Data Modeling Using E-R Diagrams 3
What is data model
Depicts structure of database.
Database Structure, we mean types, relationships,
and constraints
Data Model (modeling technique) provides a set of
concepts that can be used to describe database
structure.
-
8/13/2019 Data Modeling.1
4/35
5-Sep-11 Data Modeling Using E-R Diagrams 4
Term gotcha
Company (relational) Schema is a data model
Using relational implementation data model
-
8/13/2019 Data Modeling.1
5/35
-
8/13/2019 Data Modeling.1
6/35
5-Sep-11 Data Modeling Using E-R Diagrams 6
Types of Data Model Conceptual or Higher Data Model
Easily understood by End-Users and Managers
Capturing of Correct and Complete data is goal here
Implementation model
This modeling technique is what on which DBMS are based
Relational, Object Relational, OO are the examples.
Physical Model (normally hidden by DBMS) Depicts how files are stored on disk deals with file
organization, indexes, clustering etc
-
8/13/2019 Data Modeling.1
7/35
5-Sep-11 Data Modeling Using E-R Diagrams 7
We have seen-
Relational as Implementation model
Have a basic unit of database called a relation.
Relations are stored on disk transparent to the user
Relational Model provides
Means by which you can define database structures as
relations and constraints on relations
Also defines various operations that can be used tomanipulate relations and hence database operations are
defined in logical manner
-
8/13/2019 Data Modeling.1
8/35
5-Sep-11 Data Modeling Using E-R Diagrams 8
Conceptual Model Correct and Formal representation of data items are the
objectives here
Intuitive and Simple to understand end users andmanagers can easily understand
Centers on what data items and business rules itcontains not on how they are stored or organized inapplication (or structured in a DBMS logically orphysically)
ER Diagrams and UML class diagrams are popularConceptual models
Implementation neutral (relational or whatever it is)
-
8/13/2019 Data Modeling.1
9/35
5-Sep-11 Data Modeling Using E-R Diagrams 9
E-R Diagram (or Model ? )
As said, it is a popular high level Conceptual Data
Model
ER Diagram are simple, consists of just three concepts-
Entities contains their name and attributes Relationshipbetween entities
Cardinality/Participation Constraints on entities for
their participation into relationships
Let us understand what these terms mean here?
-
8/13/2019 Data Modeling.1
10/35
5-Sep-11 Data Modeling Using E-R Diagrams 10
How we see data around us-
Address
....
..11-07-88Arpit060103
..10-02-89Anurag060102
..12-10-88Aditi060101
..Fasthers
Name
DOBNameStudID
List of Students IIyr BTech(CS)
..
.....
40BTech(Information Technology)BIT
40BTech(Computer Science)BCS
IntakeProgNameProgID
List of Programs Offered by CSE Department
-
8/13/2019 Data Modeling.1
11/35
5-Sep-11 Data Modeling Using E-R Diagrams 11
How do we describe this data Careful watch reveals that we have two types of entity
sets here-
Students and Programs (note: later we may discover thatit has one more entity department)
Let us call all students together an entity set, andProgram together another entity set
Each Student entity has certain properties (or attributes)like Name, DOB, Fathers Name etc., and their valuesdrawn from a predefined value set,
and similarly each program has certain attributes, andtheir values
-
8/13/2019 Data Modeling.1
12/35
5-Sep-11 Data Modeling Using E-R Diagrams 12
How do we describe this data If we attempt to describe student entity, typically it can
be like this-
Name of Entity: Student
Attributes: StudID, Name, DOB, FathersName, ..
Each Attribute derives value from a value set (domain)
StudID uniquely identifies a student entity in the set
This is description of Student entity, and we call it
Entity Type
Similarly we describe ProgramEntity Type
-
8/13/2019 Data Modeling.1
13/35
5-Sep-11 Data Modeling Using E-R Diagrams 13
ERD notation for the Entity types
Notations used here are,
originally suggested by
Dr Peter Chen in 76,
known as Chens notation
-
8/13/2019 Data Modeling.1
14/35
5-Sep-11 Data Modeling Using E-R Diagrams 14
Entities and Attributes Entity is the basic object in ER model. It is thing
which exists
Each entity has attributes- properties that describe the
entity, for example as we have seen-
Entity: Student
Attributes: StudID, Name, DOB, Fathers Name,
Address,
Entity: Program
Attributes: ProgID, ProgName, Intake
-
8/13/2019 Data Modeling.1
15/35
5-Sep-11 Data Modeling Using E-R Diagrams 15
Entities and Attributes Attributes could be
Atomic can not be meaningfully decomposed:
Example DOB can not be decomposed in
Day/Month/Year DOB is atomic data
Student-Name may or may not be atomic
If FirstName, LasteName have individual meaning
Key Attributes
Composite: Example Address (Street, City, PIN)
Single valued and multi-valued
Stored and Derived attributes
-
8/13/2019 Data Modeling.1
16/35
5-Sep-11 Data Modeling Using E-R Diagrams 16
Entities and Attributes in ERDCompositeAttribute
Multi-value
Attribute
Key
Attribute
Key attribute Uniquely Identifies an Entity in Entity Set
-
8/13/2019 Data Modeling.1
17/35
5-Sep-11 Data Modeling Using E-R Diagrams 17
Entities and Attributes
Derived
Attribute
-
8/13/2019 Data Modeling.1
18/35
5-Sep-11 Data Modeling Using E-R Diagrams 18
Entity Type Casually, very often term entity is used for Entity Type.
AnEntity Type describes schema or intention for a set of
entities sharing the same structure. In OO terminology, an entity type is similar to a class, and an
entity is similar to an instance
Definition (Elmasri/Navathe):
Entity Type defines a collection (or set)
of entities that have the same attributes.Each Entity Type in the database
is described by its name and attributes
-
8/13/2019 Data Modeling.1
19/35
5-Sep-11 Data Modeling Using E-R Diagrams 19
Entity Set The collection of entities of a particular entity type are
grouped into an entity set, is also called extension of entity
type. The entity set usually referred with the same name as of
Entity Type
Address
....
..11-07-88Arpit060103
..10-02-89Anurag060102
..12-10-88Aditi060101
..FasthersName
DOBNameStudID
Definition (Elmasri/Navathe):The collection of all entities of a particular type
in the database at any point of time is called an entity set.
-
8/13/2019 Data Modeling.1
20/35
5-Sep-11 Data Modeling Using E-R Diagrams 20
Key Attributes It is Attribute or set of Attributes, called Key Attribute
which are used to uniquely identify the entity in the set
An important constraint on entities of an entity type isthe key constraint or uniqueness constraint.
Key
Attribute
Address
..
11-07-88Arpit060103
10-02-89Anurag060102
12-10-88Aditi060101
DOBNameStudID
-
8/13/2019 Data Modeling.1
21/35
5-Sep-11 Data Modeling Using E-R Diagrams 21
Value Sets (Domains) of Attributes
Each simple attribute of an entity type is associated
with a value set (or a domain of values), whichspecifies the set of values that may be assigned to that
attribute for each individual entity
Also known as domain constraint on an attribute
-
8/13/2019 Data Modeling.1
22/35
5-Sep-11 Data Modeling Using E-R Diagrams 22
What we have talked about is
Entity: for example a student rahul
Entity Type: student
Entity Set: set of all entitities belonging to a
type, for example all students
-
8/13/2019 Data Modeling.1
23/35
-
8/13/2019 Data Modeling.1
24/35
5-Sep-11 Data Modeling Using E-R Diagrams 24
Relationship Type, Instance, and Set Let us look at following facts
Aditi studies in BIT
Amit studies in BCS
Arpit studies in BIT
Varun studies in BEE
Radhika studies in BIT
Shyam studies in BCS
This showsRelationshipbetween Student and Programentities (entity types to be precise) let us give aname to it Studies obvious choice
Relationship also has type and set, here studies isRelationship Type,
Each of above statement is instance of the type, andAll together form relationship set
-
8/13/2019 Data Modeling.1
25/35
5-Sep-11 Data Modeling Using E-R Diagrams 25
Relationship Instance Diagram
Relationship
Set
-
8/13/2019 Data Modeling.1
26/35
5-Sep-11 Data Modeling Using E-R Diagrams 26
Simple ER Diagram: Student-Program
Relationship
-
8/13/2019 Data Modeling.1
27/35
5-Sep-11 Data Modeling Using E-R Diagrams 27
Relationships can also have attributes In our previous example, suppose we also want to have
study duration of a student in a program, then
Let us say, we have attributes year_from, and year_to
Can you create relationship instance diagram for this?
-
8/13/2019 Data Modeling.1
28/35
-
8/13/2019 Data Modeling.1
29/35
5-Sep-11 Data Modeling Using E-R Diagrams 29
How do we identify entities in a scenario ?
Some thumb Rules:
When recite the scenario description, nouns and
objects are candidate for entity, and
Verbs are candidate for relationship between
entities
For example read next slide.
-
8/13/2019 Data Modeling.1
30/35
-
8/13/2019 Data Modeling.1
31/35
5-Sep-11 Data Modeling Using E-R Diagrams 31
ERD for XIT database
-
8/13/2019 Data Modeling.1
32/35
5-Sep-11 Data Modeling Using E-R Diagrams 32
XIT Scenario - modified X Institute of Technology (XIT) has a number of
departments.
Each department offer a number of programs
Each program has a definite category wise approvednumber of sheets; that is state quota, and national
quota, and in each quota you have Gen, SC, ST, etc.
Students are registered in various programs as peravailable seats in each category.
-
8/13/2019 Data Modeling.1
33/35
5-Sep-11 Data Modeling Using E-R Diagrams 33
How do we identify entities
Let us give a try to another relatively new scenario and
figure out entities, their attributes, and relationships init.
-
8/13/2019 Data Modeling.1
34/35
5-Sep-11 Data Modeling Using E-R Diagrams 34
IBM TGMC A number of Teams from various institutes Participate in the
competition.
Each Team has a mentor, a faculty from same institute
Every team has to register online at their site www.tgmc.in,
while registering they are required to furnish following
details- Team Name, Login ID, Password, team members
(email id and contact number), mentor and institute names
IBM awards to Winner, Runner and top 20 teams.
Also they award best 10 participating institutes
Objective of Database: IBM want to keep record of all
teams registered for the event and for there after math
-
8/13/2019 Data Modeling.1
35/35
5-Sep-11 Data Modeling Using E-R Diagrams 35
Thanks