Creating a Relational Database Using Microsoft Access
A Relational Database is….. A database that has more than one table in it
The main table has to have… Each table has to have….. Fields in it One of the fields has to be a primary field The main table has to have… A unique primary field
Each table has to have a relationship to the other tables This means that some field names in each table need to be the same
An example of relationships in a travel company database We have three tables: The customerid field is common to both customers and flights – this builds their relationship The hotelid field is common to both flights and hotels – this builds their relationship The three tables are therefore linked together
The travel ‘relationship’ explained Any customer can have many hotels and any hotel can have many customers. This is called…. A MANY TO MANY RELATIONSHIP This relationship cannot be created, so, we need a link table to create these relationships. This is the FLIGHT table – it ‘delivers’ the customers to the hotels.
The travel ‘relationship’ understood If you have a flight table you can now build: A ONE TO MANY RELATIONSHIP Where: A customer can have many flights, and:- A hotel can have many customers delivered to it through many flights.
Advice for creating your own travel firms relational database Choose your table headings carefully – always end them with tbl, for example customertbl. Don’t use more than 3 tables to create your relational database. Choose your field headings for each table carefully – make sure each table has a primary field that links into another table, for example the customerid is in both the customer table and the flights table. Make sure that one of your tables has a unique primary field called customer id – and that this field is an automatic number