(DBMS_2) ER Model
It helps to build database as correct and quick as possible and fit the demand of user, apps, business.
- It provides a preview of how all your tables should connect and what filed are going to be on each table.
- It helps to describe entities, attributes, relationships
To help explaining the logics of database. Three basic concepts: entities, attributes, relationships.
example of Entity Relationship Diagram:
Real World Example:
- Entity: Anything in real world
> weak entity means anything existing because an entity exists; for example, a car belongs to CEO in a company. If the CEO leaves a company, then this CEO car should also be eliminate from database.
2. Relation: define the relationship between entities
3. Attribute: the characteristic of entity
4. Cardinality: define the type of relationship: One-to-One, One-to-Many, May to One, Many-to-Many
There are five steps:
With following example:
In a market, there are a lot of people, both buyers and sellers, sellers has a lots of goods and buyers use money to buy them. Of course, the buyer can also sell what they bought. Then, the design should be as follow:
Step1: Define Entities:
we should have three entities: sellers, buyers, goods
Step2: Define Relationship
Sellers have some goods and buyers want to buy somethings.
This market stipulates each seller can only sell a goods and buyers can buy many goods.