Constructing an ER model :
Before beginning to draw the ER model, read the requirements specification
carefully. Document any assumptions you need to make.
1. Identify entities – list all potential entity types. These are the object of interest in
the system. It is better to put too many entities in at this stage and them discard
them later if necessary.
2. Remove duplicate entities – Ensure that they really separate entity types or just
two names for the same thing.
○ Also do not include the system as an entity type
○ e.g. if modeling a library, the entity types might be books, borrowers, etc.
○ The library is the system, thus should not be an entity type.
3. List the attributes of each entity (all properties to describe the entity which are
relevant to the application).
○ Ensure that the entity types are really needed.
○ are any of them just attributes of another entity type?
○ if so keep them as attributes and cross them off the entity list.
○ Do not have attributes of one entity as attributes of another entity!
4. Mark the primary keys.
○ Which attributes uniquely identify instances of that entity type?
○ This may not be possible for some weak entities.
5. Define the relationships
○ Examine each entity type to see its relationship to the others.
6. Describe the cardinality and optionality of the relationships
○ Examine the constraints between participating entities.
7. Remove redundant relationships
○ Examine the ER model for redundant relationships.
ER modeling is an iterative process, so draw several versions, refining each one
until you are happy with it. Note that there is no one right answer to the problem,
but some solutions are better than others!
Example:
Construct an ER diagram for a Banking System. Clearly indicate the
entities, relationships, cardinality and the key constraints. Also, derive
the un-normalized relational database tables with the help of this
diagram.
The General Things needed in a Banking System are: –
1. Person Opens an Account
2. Person using ATM for Transaction
The person opens an Account in a Bank and gets an account number
and ATM card. The person can make transactions in ATM centres. The
Details of the Transaction has to be maintained Between Three Entities. i.e.
User, Account, ATM
Make a list of Entities with attributes
Entity_Name
Attribute Data Type Description(If any Constraints
specific)
User
Attribute Data Type Description(If any Constraints
specific)
User_ID Number User ID Primary key
(auto increment)
Not null
Name (First_Name, Last_Name) Varchar User Name Not null
Address Varchar User Address Not null
Contact_Number Varchar User contact number Not null
Account
Attribute Data Type Description(If any Constraints
specific)
Account_Number Number User Account Primary Key
Number (Auto Increment)
Not Null
User_ID Varchar User ID from User Foreign Key
----------- table Not null
Account_Type Varchar Types of account Not null
-Saving_Account,
-Current_Account,
-Over_draft_Account
Balance Number Balance of the AC Not null
ATM
Attribute Data Type Description(If any Constraints
specific)
ATM Number Number Identifier number for Primary Key
ATM Card (Auto Increment)
Not Null
ATM_Place Varchar Location of ATM The Not null
card has been used.
ATM_Cash_Limit Number How much Cash Can Not null
be withdrawn from the
ATM per transaction
Opening_Account
Attribute Data Type Description(If any Constraints
specific)
Date Date Date of opening Not Null
account
User_ID Varchar User ID from User Foreign Key
----------- table Not null
Account_Number Number User Account Number Primary Key
------------------------- Foreign Key
Not null
ATM_Number Number ATM number for the Foreign Key
--------------------- ATM Card Not null
Transaction
Attribute Data Type Description(If any Constraints
specific)
Date Date Date of Transaction Not Null
Time TIMESTAMP(fsp) Time of Transaction Primary Key
Not null
User ID Varchar User ID from User Primary Key
---------- table Foreign Key
Not null
Account Number Number User Account Number Foreign Key
---------------------- Not null
ATM Number Number ATM number for the Foreign Key
ATM Card Not null
Transaction Type Varchar Deposit cheque Not null
Deposit Cash
Withdraw Cash
Amount Double Amount of transaction Not Null
Reference
1. [Link]
2. [Link]
-[Link]
3. [Link]
early-indicate-the-entities-relationships-cardinality-and-the-key-constraints-also-deriv
e-the-un-normalized-relational-database-tables-with-the-help
4. Data Type in MYSQL: [Link]
5. Key constraints in MYSQL :
[Link]
QL%20allows%20assigning%20FOREIGN%20KEY,KEYs%20belonging%20to%20differ
ent%20tables.&text=If%20you%20want%20to%20do,'newpurchase'%20will%20be%20c
reated.
6. Composite Key: [Link]