How to Design a Database?

  • Talk to the stakeholder for which we are designing the database. Get all the requirements, what attributes need to be stored, and establish functional dependencies over the given set of attributes.
  • Draw an Entity-Relationship Diagram on the basis of requirements analysis.
  • Convert the ER diagram into the relational model and finally create these relations into our database with appropriate constraints.

Designing ER Diagrams is easier than finding minimum relations that satisfy the First Normal Form. We establish certain simple rules which are formed after a deep analysis of each case and hence, could be used directly by understanding the logic behind them.

  • If there is total participation on both sides; Merge the two entities involved and the relationship into 1 table.
  • Else if, one side is total participation and one side is partial
    • M: N – Merge the relationship on the total participation side.
    • 1: N – Merge the relationship on the total participation side.
    • 1: 1 – Merge the two entities involved and the relationship into 1 table.
  • Else if, both sides are partial participation
    • M: N – Separate table for each entity as well as relationship. Hence, 3 tables.
    • 1: N – Merge the relationship on the N-side using foreign key referencing 1-side.
    • 1: 1 – Merge the relationship and one entity into 1 table using the foreign key and 1 table for the other entity.

Now, you would definitely have a question in your mind, how do we form such rules? This is very easy and logical. Let’s understand the logic behind it for one case and you can similarly establish the results for other cases too. We have been given a scenario of a 1:N relationship with two entities E1(ABC) and E2(DEF), where A and D are primary keys, respectively. E1 has partial participation while E2 has total participation in the relationship R. Based on the above scenario, we create certain tuples in E1:

A

B

C

a1

b1

c1

a2

b2

c2

a3

b3

c3

Similarly, create certain tuples for E2:

D

E

F

d1

e1

f1

d2

e2

f2

d3

e3

f3

Now, create a relationship R satisfying the above conditions, i.e. E1 is partial participation and E2 is total participation, and E1 to E2 is a 1:N relationship.

A

D

a1

d1

a1

d2

a2

d3

Minimum Relations Satisfying First Normal Form (1NF)

A relation that does not contain any composite or multivalued attribute, then the relation is in its First Normal Form. Relations that contain a single-valued attribute comes under First Normal Form. In this article, we will be going to discuss the minimum relations satisfying the First Normal Form. Before proceeding to First Normal Form, let’s discuss how to design a database.

Similar Reads

How to Design a Database?

Talk to the stakeholder for which we are designing the database. Get all the requirements, what attributes need to be stored, and establish functional dependencies over the given set of attributes. Draw an Entity-Relationship Diagram on the basis of requirements analysis. Convert the ER diagram into the relational model and finally create these relations into our database with appropriate constraints....

Ways of Merging Two Entities into a Single Table

Way-1: Merge the two entities and relationships into a single table. This is not correct as (AD) will become the primary key for this table, but the primary key can never have a NULL value....

Frequently Asked Questions

1. What relations are in 1NF?...