Export

You might also like

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

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. https://www.guru99.com/er-diagram-tutorial-dbms.html
2. https://www.assignmentpoint.com/business/marketing-business/assignment-on-entity
-relationship-model.html
3. http://cssimplified.com/assignments/construct-an-er-diagram-for-a-banking-system-cl
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: ​https://www.w3schools.com/sql/sql_datatypes.asp


5. Key constraints in MYSQL :
https://www.w3resource.com/mysql/creating-table-advance/constraint.php#:~:text=MyS
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: ​https://beginnersbook.com/2015/04/composite-key-in-dbms/

You might also like