Section 9.2
9 Databases
9.2 Introduction To Relational Databases
Relational databases consist of a number of linked tables.
An entity is an occurrence in a table. An entity can be thought of as a
record.
In database design the entities are identified first.
Each entity has several attributes. These can be thought of as fields.
9.2.1 Table Notation
The standard notation to describe the structure of a table in the database is
based on the attributes of one entity.
Example
Book(Library_Code, Title, Author, ISBN, Edition)
The entity is written first and conventionally a word or singular name.
The primary key is the first attribute written in the brackets and is
underlined. Other attributes follow, separated by commas.
9.2.2 Entity Relationship Modelling
The entities (and therefore the tables) in a relational database can be related
to each other in any one of three ways:
- One-to-one
- One-to-many
- Many-to-many
Example
- A blind person and a guide dog have a one-to-one relationship.
- A hospital and a patient have a one-to-many relationship.
- Films and actors have a many-to-many relationship.
9.2.3 Entity Relationship Diagrams
The entity relationships can be shown graphically.
9.2.4 The Conceptual Model
When designing a database system:
- Identify the entities.
- List the relationship pairs between the entities.
- Draw an ER diagram for the whole system.
Example
Entities: