Database Assignment 1
Database Assignment 1
2
2
TO DETERMINE THE PURPOSE OF THE SYSTEM TO DETERMINE THE FIELDS WE NEED TO IDENTIFY FIELDS WITH UNIQUE VALUES TO DETERMINE THE RELATIONSHIPS BETWEEN TABLES
3 3 3 3
RELATIONSHIPS BETWEEN TABLES ARE GROUPED INTO 4 GROUPS: 4 TO REFINE THE DESIGN TO ENTER DATA AND CREATE OTHER SYSTEM OBJECTS HOW A RELATIONAL DATABASE ORGANISES ITS DATA? SOME OF THE ELEMENTS OF TABLE STRUCTURE. PRIMARY KEYS CANDIDATE KEY: COMPOUND KEY: INDEXING 4 4 5 5 6 6 6 7
Indexing
addresses in a different table from the customers' orders, so that we could delete one order and still maintain the customer information).
To identify fields with unique valuesIn order to connect information stored in separate tables (e.g. To connect a customer with all the customer's orders) each table in our database must include a field or set of fields that uniquely identifies each individual record in the table. Such a field or set of fields is called a primary key.
1. One-to-one (1:1) - each record in Table A can have only one matching record in Table B, and each record in Table B can have only one matching record in Table A. A one-to-one relationship is created if both of the related fields are primary keys or have unique indexes. 2. One-to-many (1:M) - is the most common type of relationship and it is used to relate one record in a table with many records in another table. In a one-tomany relationship, a record (parent) in Table A can have many matching records (children) in Table B, but a record (child) in Table B has only one matching record (parent) in Table A. This kind of relationship is created if only one of the related fields is a primary key or has a unique index. 3. Many-to-one (M:1) - is used to relate many records in a table with only one (single) record in another table. It is often called the lookup table relationship. Many-to-many (M:M) - is used to relate many records in a table with many records in another table.
From our assignment we can say as example. The Bicycle Explore database includes a table that described a customer with columns for name, address, phone number and so forth. Another table describes trip id, trip date, bike route, difficulty level, route length, departure time, total price. A user of the database could obtain a view if the database that fitted the users need. For example Manager for The Bicycle Explore might like a view or report which trips were the most popular and for how many bookings. May be a client might want to know how many bookings is made on a specific date. While creating a relational database, we can define the domain of possible values in a data column and further and further constraints that may apply to that data value. For example, a domain of possible customers could allow up to ten possible customer but be constrained in one table to allow only three of these customer names to be specific.
Jo Walton
2341287
Ctl09
First Class
Gary Harman
1298731
Ctl07
Second Class
Gareth Jenkins
4236542
Ctl08
First Class
The design of a table is set before any data is entered, it can be changed afterwards, but it may corrupt the data - e.g. if we changed, the name field in the table above replacing it with "given name" and "family name".
In Access, the table is designed in the Design View window, and the data can be entered using the Table view In design view, each field has a name data type and description, and at the bottom there are further attributes (which depend on the data type)
Primary Keys
Every record in database must be unique, therefore it must have either a single field which is always different, or a combination of fields which is always different The field/s which are always going to be unique are called the primary key Choosing an appropriate primary key is very important, for instance in the student records database name, address, date of birth, or any combination of those would not be OK. The only possible candidates are the student number and the login ID
Candidate Key:
The fields or groups of fields, which could function as a primary key. Generally you should choose a key made up of the smallest number of fields
Compound key:
When a primary key is made up of more than one field Access can automatically add an auto number field to be used as a primary key. We should never need to use an auto number. The only time it is appropriate is when the only candidate keys are large compound keys
Indexing
Indexing a field makes searches on that field faster, so if we know that we will search on that field frequently we might make it an index (e.g. if we will often want to search on login)
However, it takes up more space in the database - every time a new record is added, a new entry is added to the stored index. You can choose to force all indexed entries to be unique.