The relational database is a database design format that allows the data to be stored in different tables according to certain criteria and to ensure data integrity by establishing relationships between these tables. Although the database is fully designed to meet the needs of the project, there are some basic rules for determining the relationship between database tables and ensuring normalization.
The following example is important to understand the relationship between the tables.
As seen in the tables, the data are divided into tables according to clear criteria instead of being kept in a single table. When we examine the tables, we can reach the following results.
- This relational database seems to be part of a company.
- A company has many departments and workers in these departments.
- In addition, these departments carry out various projects and the workers are Works on in these projects.
- Relationships can be between concrete entities such as workers and departments, or between abstract entities such as projects and works.
Primary Key and Foreign Key Concepts
Primary Key: It is the key to separate a record in the table from other records. For example, the SSN (Social Security Number) can be a primary key. Because there cannot be two employee with the same SSN. However, the employee name cannot be a primary key because there may be more than one employee with the same name.
Foreign Key: This is the key that corresponds to the Primary Key field in the main table.