Вы находитесь на странице: 1из 35

Conceptual Data Modeling Using E-R Diagrams

PM Jat
pm_jat@daiict.ac.in

What is data model ?

You have seen some data models.


Company Schema (in relational model) Some example of ER diagram

Depicts structure of database.

5-Sep-11

Data Modeling Using E-R Diagrams

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.

5-Sep-11

Data Modeling Using E-R Diagrams

Term gotcha

Company (relational) Schema is a data model Using relational implementation data model

5-Sep-11

Data Modeling Using E-R Diagrams

Data Model

Recall: Logically database is set of Entities There are various modeling techniques that are used to describe these entities, relationship between, various existential and other business constraints (rules).

5-Sep-11

Data Modeling Using E-R Diagrams

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
Data Modeling Using E-R Diagrams 6

5-Sep-11

We have seenRelational 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 to manipulate relations and hence database operations are defined in logical manner
Data Modeling Using E-R Diagrams 7

5-Sep-11

Conceptual Model

Correct and Formal representation of data items are the objectives here Intuitive and Simple to understand end users and managers can easily understand Centers on what data items and business rules it contains not on how they are stored or organized in application (or structured in a DBMS logically or physically) ER Diagrams and UML class diagrams are popular Conceptual models Implementation neutral (relational or whatever it is)
Data Modeling Using E-R Diagrams 8

5-Sep-11

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 Relationship between entities Cardinality/Participation Constraints on entities for their participation into relationships Let us understand what these terms mean here?
Data Modeling Using E-R Diagrams 9

5-Sep-11

How we see data around usList of Students IIyr BTech(CS)


StudID 060101 060102 060103 .. Name Aditi Anurag Arpit DOB 12-10-88 10-02-89 11-07-88 Fasthers Name Address .. .. ..

.. List of Programs Offered by CSE Department ProgID BCS BIT .. .. .. ProgName BTech(Computer Science) BTech(Information Technology) . Intake 40 40 ..
10

5-Sep-11

Data Modeling Using E-R Diagrams

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 that it has one more entity department) Let us call all students together an entity set, and Program together another entity set Each Student entity has certain properties (or attributes) like Name, DOB, Fathers Name etc., and their values drawn from a predefined value set, and similarly each program has certain attributes, and their values
Data Modeling Using E-R Diagrams 11

5-Sep-11

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 Program Entity Type
Data Modeling Using E-R Diagrams 12

5-Sep-11

ERD notation for the Entity types

Notations used here are, originally suggested by Dr Peter Chen in 76, known as Chens notation
5-Sep-11 Data Modeling Using E-R Diagrams 13

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 seenEntity: Student Attributes: StudID, Name, DOB, Fathers Name, Address, Entity: Program Attributes: ProgID, ProgName, Intake
Data Modeling Using E-R Diagrams 14

5-Sep-11

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
Data Modeling Using E-R Diagrams 15

5-Sep-11

Entities and Attributes in ERD


Composite Attribute

Key Attribute

Multi-value Attribute

Key attribute Uniquely Identifies an Entity in Entity Set


5-Sep-11 Data Modeling Using E-R Diagrams 16

Entities and Attributes

Derived Attribute

5-Sep-11

Data Modeling Using E-R Diagrams

17

Entity Type

Casually, very often term entity is used for Entity Type. An Entity 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
5-Sep-11 Data Modeling Using E-R Diagrams 18

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
StudID 060101 060102 Name Aditi Anurag DOB 12-10-88 10-02-89 Fasthers Name Address .. .. ..

Definition (Elmasri/Navathe): 060103 Arpit 11-07-88 .. The collection of all entities of a particular type in the database.. at any point of time is called an entity set. ..
5-Sep-11 Data Modeling Using E-R Diagrams 19

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 is the key constraint or uniqueness constraint.
StudID 060101 060102 060103 Name Aditi Anurag Arpit DOB 12-10-88 10-02-89 11-07-88 Address

Key Attribute

..

5-Sep-11

Data Modeling Using E-R Diagrams

20

Value Sets (Domains) of Attributes


Each simple attribute of an entity type is associated with a value set (or a domain of values), which specifies the set of values that may be assigned to that attribute for each individual entity Also known as domain constraint on an attribute

5-Sep-11

Data Modeling Using E-R Diagrams

21

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

5-Sep-11

Data Modeling Using E-R Diagrams

22

Next: Relationships.

5-Sep-11

Data Modeling Using E-R Diagrams

23

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 shows Relationship between Student and Program entities (entity types to be precise) let us give a name to it Studies obvious choice Relationship also has type and set, here studies is Relationship Type, Each of above statement is instance of the type, and All together form relationship set
Data Modeling Using E-R Diagrams 24

5-Sep-11

Relationship Instance Diagram

Relationship Set

5-Sep-11

Data Modeling Using E-R Diagrams

25

Simple ER Diagram: Student-Program

Relationship

5-Sep-11

Data Modeling Using E-R Diagrams

26

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

5-Sep-11

Can you create relationship instance diagram for this? Data Modeling Using E-R Diagrams 27

A relationship instance is identified in its set by key attributes of participating entities

5-Sep-11

Data Modeling Using E-R Diagrams

28

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.

5-Sep-11

Data Modeling Using E-R Diagrams

29

XIT Scenario

X Institute of Technology (XIT) has a number of departments. Each department offer a number of programs Each program has a definite approved number of seats, and students are registered in various programs against these seats

5-Sep-11

Data Modeling Using E-R Diagrams

30

ERD for XIT database

5-Sep-11

Data Modeling Using E-R Diagrams

31

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 approved number 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 per available seats in each category.

5-Sep-11

Data Modeling Using E-R Diagrams

32

How do we identify entities

Let us give a try to another relatively new scenario and figure out entities, their attributes, and relationships in it.

5-Sep-11

Data Modeling Using E-R Diagrams

33

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
Data Modeling Using E-R Diagrams 34

5-Sep-11

Thanks

5-Sep-11

Data Modeling Using E-R Diagrams

35

Вам также может понравиться