Académique Documents
Professionnel Documents
Culture Documents
Introduction to Databases
Structure and Organization
Tables, Fields, Records
Encoding Relationships
Microsoft Access
What is a database?
A (typically large) collection of data about a particular topic
Examples of databases:
30/04/2014
Aspects of Databases
MySQL
Oracle
30/04/2014
Database Organization
30/04/2014
Relational Databases
Entities
Things about which we store information
Relationships
Specific connections among entities
E.g., Paul Smith is enrolled in CompSci111
Usually expressed simply (e.g., customers who made orders)
Often one to many (e.g., one customer can make many orders)
Edgar Codd
30/04/2014
Some Definitions
Relationships Example
30/04/2014
30/04/2014
10
Primary key
30/04/2014
11
30/04/2014
12
30/04/2014
13
30/04/2014
Exercises
14
Exercises
30/04/2014
15
30/04/2014
16
Referential Integrity
Example:
Suppose Student in the Academic Transcript table is a linked by
foreign key to ID in the Student table, a primary key.
17
30/04/2014
Types of Relationships
18
Types of Relationships
One to one
An in table A is related to a unique entity in table B.
E.g., each person may have a unique spouse.
Many to many
Different entities in table A and table B can occur together.
Implemented indirectly through two one-to-many relations.
30/04/2014
19
30/04/2014
20
Microsoft Access
One widely used database management system is Microsoft
Access.
Using this software, we can:
Create database tables and relations
Create blank
database or
use templates
30/04/2014
File save
location
21
30/04/2014
22
The Design View lets you set or view the fields your table is characterised
by.
The Datasheet View is used to view or enter data.
Choose
Table,
Query, or
Report
23
30/04/2014
24
Field name
Field type
Description
(optional)
25
30/04/2014
30/04/2014
Selecting Relationships
Adding the two tables to the relationship diagram (if not present)
26
Adding Relationships
30/04/2014
27
30/04/2014
28
More Exercises
Exercise 5: What is the primary key and the foreign key (if
one exists) for the Customers table?
This would expunge all records related to that student in the Academic
Transcript table if you check Cascade Delete Related Records.
Generally not a good idea, e.g. if the deletion is done by mistake.
30/04/2014
29
Exercise 6: What is the primary key and the foreign key (if
one exists) for the Room Booking table?
Exercise 7: What is the primary key and the foreign key (if
one exists) of the Room Information table?
30/04/2014
30