2023. 1. 15. 22:21ㆍData science/Database
ER Design phase
1. Requirements analysis: what problem is being solved? What does the DB need to do?
2. Logical design: Identification of entities and their relationships (ER model)
3. Normalization: systematic simplification and clarification of the logical design
4. Physical Design: implementation in DBMS
ER model concepts
1. Entity: thing, A noun
2. Attribute: a property, An adjective (PK mark with *)
3. Relationship: a semantic link, A verb (two entity relationship: Binary, three entity type involve:Ternary)
4. Instance: Different data of Entity (another tuple)
** PKs, FKs, and data constraints will be added during DB implementation, but they should also be considered during conceptional design.
Cardinality constraints
How many instances of entity types can take part in the relationship between them????
The entity has various instances - which is a set of attribute values. (I would say each row from the table)
So, how many are they related to the other table? will decide the cardinality. (Zero, One or Many)
-> In other words, for each relationship, mark the minimum and maximum cardinality. Check out the Figure 2.
- Zero or Many: Location can have zero or Many Location_Player - in other words
- One or Many: One or Many relationships
- Zero or One: Location_player can be included zero or one location. (MAY)
- One and Only one: Test_table can have one and only one Location. (MUST)
※Many to Many relationship
: this can be due to the violates atomicity(each attribute holds only one single value)
-> solution: Introduce new joining(bridging /intersection/junction) entity.
Crow's foot diagram
Many signs look like crow's feet. Thus it is called the "crow's foot diagram".
There is also another famous one called "Chen Notation".
Weak Entity
If a certain entity's existence totally depends on another entity, we call it a weak entity. For instance, hotel_Room can not exist if the hotel does not exist; thus, hotel_room is a weak entity. This Weak entity doesn't have PK. Instead, it has a discriminator/partial key. Which can be composited with PK of the parent table, and the composite of PK of the parent table + Discriminator used as a composite key. (Hotel.id + room.number can be used as identifier)
Strong entity(Regular entity)
Constraints(NOT NULL), defaults(NONE, ZERO, etc.), and keys(PK, AUTO_INCR, FK) must be given.
'Data science > Database' 카테고리의 다른 글
Understanding database 6 - Normalization (0) | 2023.01.15 |
---|---|
Understanding Database 5 - Advanced SQL Queries (Stored Procedure, Trigger, Views) (0) | 2023.01.15 |
Understanding Database 3 - Relational Algebra (관계대수) (0) | 2023.01.15 |
Understanding Database 2 - SQL (0) | 2023.01.15 |
Understanding Database 1 - Database (0) | 2023.01.15 |