s1.3 Review Database.pptx
s1.3 Review Database.pptx
For example:
Customer Product
Order
Database Example
Customer
Database Example
Product
Database Example
Order
What is Database?
A collection of related data in a certain context
an entity
Relational Database
A relational database is a collection of data items with pre-defined relationships
between them.
These items are organized as a set of tables with columns and rows.
Relational Database
Customer Table
Nguyễn Văn A
1175222
903455322 03/27 23411242 04 Pham Ngu Lao, Q.1 1175222 1
Primary key
An attribute (or a list of attributes) that uniquely identifies each row in a table
Primary key
A column (or a list of attributes) that uniquely identifies each row in a table
- No duplicate primary key value
- Every row must have a value in primary key column (primary key cannot be null)
- Value in primary key column should not be modified once created
Foreign key
A referencing key to link two tables together
Foreign key
Foreign key
A referencing key to link two tables together
Foreign key
Entity Relationship Diagram
An Entity Relationship (ER) Diagram is a type of flowchart that illustrates how “entities”
such as people, objects or concepts relate to each other within a system.
Entity Relationship Diagram
Entities
Attributes
Entity Relationship Diagram
- Reminder: this is One-to-Many relationship
- To determine optionality, ask this question: Does Entity A have to have entity B?
If Yes: place a single vertical line next to B If No: place a circle next to B
Entity A must have at least 1 Entity B Entity A doesn’t have to have Entity B