Relational Databases Flashcards
What is a database?
A collection of organised data that allows access, retrieval, and use of that data.
What is a Relational database?
a collection of related/ linked tables
E.g. all of the student tables for NMHS and subject details tables and specific class details tables.
How is data stored in a DBMS?
Data is grouped into tables (normalisation) and stored in records and fields.
DBMS role
Process data to produce meaningful information for a user by applying, sorting, and/or grouping.
Store data in a way that reduces data redundancy.
Normalisation principles
The need to minimise the duplication of data.
Primary key
Consists of one or more fields that uniquely identifies each record in a table. The data in a primary key is unique to a specific record.
Non-key fields are dependent on the key, and not dependent on any other field.
Factless identifiers are ideal for use as a primary key because they do not change E.g. AutoNumber
Name Examples: Employee ID, Student ID
Foreign key
Tables are linked by joining the primary key from the table on the one-side to the appropriate field, which is called the foreign key, on the many-side.
Composite key
A composite key can be applied in the transaction table to prevent a double transaction.
When a primary key consists of more than one field.
Field
a set of related characters
a single item type of information that appears in every record.
If you want to sort, search, calculate, or report based on an item of information, you should put that item in its own field.
E.g. on a student id card- ‘surname’ is a field
Record
a collection of related fields
a meaningful and consistent way to combine information about something
E.g. everything on a student ID card makes up one record
Tables
a collection of related records.
Lists of rows and columns
E.g. all students enrolled on the SC of NMHS
What are the 3 links between table called?
- One-to-one
- One-to-many
- Many-to-many.
One - to - many
a row in table A can have many matching rows in table B. But a row in table B can have only one matching row in table A.
Only occurs if one of the related columns is a primary key or has a unique constraint
e.g. Each ‘Publisher’ produces many titles. But each ‘Title’ comes from only one ‘Publisher’.
Many - to - many
a row in table A can have many matching rows in table B, and vice versa.
E.g. a single ‘Order’ can include more than one ‘Product’, and a single ‘Product’ can appear on many ‘Orders’.
Solving many to many relationships
The solving of a many-to-many relationship can be achieved by adding a transaction/junction table.