Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

Data Modeling

MODEL :A Model is an abstraction of something for the purpose of


understanding it before building it.

It answers a set of following specific questions that are


relevant to any data processing application The following
questions answered by a Data Model:

(1)What are the primary data objects to be processed by the system


(2)What is the composition of each data object and what attributes
describe the object
(3)Where do objects currently reside
(4)What are the relationships between each object and other
objects
(5)What is the relationship between the objects and the processes
that transform them

To answer those questions, Data modeling makes use of Entity-


Relationship diagram(ERD).

ERD enables a Software Engineer to identify data objects and their


relationships using a graphical notation

DATA OBJECTS

A data object is a representation of almost any composite


information that must be understood by software. By composite
information, we mean something that has a number of different
properties or attributes.

A person is a data object


A car is a data object

Key  One or more attributes which uniquely identify a data object

Attributes of Person: Name, Address, Age, Driving license number


Driving license number is the key

Attributes of Car: Make, Model, Chassis Number, Body type, Color


Chassis Number is the key

RELATIONSHIPS

Data objects are connected to one another in a variety of


different ways Here, owns is the relationship

Example: A Person owns a Car

NOTES // MUKHERJEE // DATA MODELING 1


Identification of Objects, Attributes & Relationships

Problem Definition:

A University should schedule its class rooms for final Exams.


Examinations will be conducted for all courses for students of all
sections

We have three objects in this problem. They are

(1) Course
(2) Section
(3) Room

Attributes for the above objects are as follows:

Attributes for COURSE:

- Name
- Department
- Code

Attributes of SECTION:

- S_Number
- Enrollment

Attributes of ROOM:

- R_Number
- Capacity
- Building

Relationships for the above objects:

- Code & S_Number

Entity Relationship Model

Simple and Composite Attributes

- CITY is a Simple attribute


- NAME is a Composite attribute because we can subdivide it into
First Name, Middle Name and Last Name

Single and Multi Valued Attributes

- AGE is a single valued attribute


- DEPENDENT_NAME is a multi valued attribute

NOTES // MUKHERJEE // DATA MODELING 2


Derived Attributes
- EMPLOYEMENT_LENGTH of Employee entity set is a derived attribute
of Start-date and Current-date.

Keys

(1) Super Key


(2) Candidate Key

For example, Consider CUSTOMER entity set with attributes


(1)Social security (2)Customer name (3)Customer street (4)Customer
city Now, Social security is a super key. Also, any set of
attributes containing Social security forms a super key.

ENTITY-RELATIONSHIP DIAGRAM

A E-R diagram consists of following components:

- Rectangles-represent Entity sets

- Ellipses-represent Attributes

- Diamonds-represent Relationship sets

- Lines-link attributes to Entity sets and Entity sets to .


relationship sets

- Double Ellipses-represent multi valued attributes

- Dashed Ellipses-denote derived attributes

- Double lines-indicate total participation of an entity in a


relationship set

E-R diagram corresponding to Customers and Loans

RELATIONSHIPS BETWEEN ENTITY SETS

-One to Many

-Many to One

NOTES // MUKHERJEE // DATA MODELING 3


-One to One

RELATIONSHIP SETS

So, Attributes of Borrower :Social Security, Loan-number

WEAK ENTITY SETS

For example, an entity set with attributes Name, Age, Height is a


Weak Entity Set

STRONG ENTITY SET

An Entity set with Passport no., Name ,age, Height, Address is a


Strong Entity Set as Passport no. can be used as key attribute

-Derived Attributes
-Candidate Keys
-Entity-Relationship Diagram

Consider the following Table:

ACCOUNT
ACCOUNT- ACCOUNT- BALANCE
TYPE NUMBER
SA 25896 50000
SA 43965 40000
SA 32963 60000
CA 56939 80000
CA 39683 30000
CA 46854 70000

Consider the following Tables:

NOTES // MUKHERJEE // DATA MODELING 4


SAVINGS ACCOUNT
ACCOUNT NUMBER BALANCE

25896 50000

43965 40000

32963 60000

CHECKING ACCOUNT
ACCOUNT NUMBER BALANCE

56939 80000

39683 30000

46584 70000

NOTES // MUKHERJEE // DATA MODELING 5


Account-number balance

Account
SPECIALIZATION
ISA

Interest-rate Overdraft-amount

Savings-account Checking-account

ISA

standard gold senior

num-checks interest-payment min-balance min-balance

In the process of Specialization, the common attributes of tables


are separated and a IS-A relationship is derived. After
Specialization, the table’s structure can be altered so that
queries can be handled more efficiently.

USER DEFINED DESIGN


CONSTRAINTS

EMPLOYEE

ANALYSIS CODING TESTING


TEAM TEAM TEAM

When you have an Employee and three teams namely Analysis Team,
Coding Team and Testing Team, he can be member of any team. Also,
he/she being the member of more than one team is not ruled out.
These are called Design constraints. These are User Defined
Constraints.

NOTES // MUKHERJEE // DATA MODELING 6


Account-number balance

Account DISJOINT
ISA CONSTRAINT
Interest-rate Overdraft-amount

Savings-account Checking-account

ISA

standard gold senior

num-checks interest-payment min-balance min-balance

You can also have disjoint constraints where an employee cannot be


member of more than one team .They can also be specified.

Consider the following Tables:

SAVINGS ACCOUNT
ACCOUNT NUMBER BALANCE

25896 50000

43965 40000

32963 60000

NOTES // MUKHERJEE // DATA MODELING 7


CHECKING ACCOUNT
ACCOUNT NUMBER BALANCE

56939 80000

39683 30000

46584 70000

ACCOUNT
ACCOUNT- ACCOUNT- BALANCE
TYPE NUMBER
SA 25896 50000
SA 43965 40000
SA 32963 60000
CA 56939 80000
CA 39683 30000
CA 46854 70000
The above tables namely CHECKING ACCOUNT and SAVINGS ACCOUNT can
be combined into a single table ACCOUNT by adding an additional
attribute which specifies the type of account.

NOTES // MUKHERJEE // DATA MODELING 8


social-security customer-street loan-number amount

customer-name customer-city

customer borrower loan

AGGREGATION loan-officer

employee
e-social security telephone-number

employee-name

In the above figure, we had relationship between three entities.


This can be depicted as follows in which we had a relationship
between an entity set and a relationship set.

social-security customer-street loan-number amount

customer-name customer-city

customer borrower loan

loan-officer

employee

e-social security telephone-number

employee-name

A Strong Entity Set is one which is having a key value. The


following is a strong entity set as the entities have keys.

NOTES // MUKHERJEE // DATA MODELING 9


STRONG ENTITY SET

social-security customer-street loan-number amount

customer-name customer-city

customer borrower loan

CUSTOMER ENTITY SET


CUSTOMER- SOCIAL- CUSTOMER- CUSTOMER-
NAME SECURITY STREET CITY
JONES 321-12-3123 MAIN HARRISON
SMITH 019-28-3746 NORTH RYE
HAYES 677-89-9011 MAIN HARRISON
CURRY 244-66-8800 NORTH RYE
LINDSAY 336-66-9999 PARK PITTSFIELD
TURNER 182-73-6091 PUTNAM STAMFORD
WILLIAMS 963-96-3963 NASSAU PRINCETON
ADAMS 335-57-7991 SPRING PITTSFIELD
JOHNSON 192-83-7465 ALMA PALO ALTO

A Weak Entity Set is one which doesn’t have a key value.For


example, the entity PAYMENT doesn’t have a key value.

NOTES // MUKHERJEE // DATA MODELING 10


WEAK ENTITY SET

payment-date

Loan-number amount
payment-number payment-amount

loan loan- payment


payment

RELATIONSHIP SETS

social-security customer-street loan-number amount

customer-name customer-city

customer borrower loan

A Relationship set is one which relates Entity Sets as shown


above.

NOTES // MUKHERJEE // DATA MODELING 11


Account-number balance

Account
GENERALIZATION
ISA

Interest-rate Overdraft-amount

Savings-account Checking-account

ISA

standard gold senior

num-checks interest-payment min-balance min-balance

social-security customer-street loan-number amount

customer-name customer-city

customer borrower loan

AGGREGATION loan-officer

employee

e-social security telephone-number

employee-name

NOTES // MUKHERJEE // DATA MODELING 12

You might also like