Docsity

Database Design using Microsoft Access: A Step-by-Step Guide, Study Guides, Projects, Research of Innovation

Toggle sidebar
bg1
CS 4700/6700 A Sample of Small Database Design Using Microsoft Access (2019)
Company relational database schema from the textbook (Fundamentals of Database systems, 7
th
Edition, by Ramez Elmasri and Shamkant Navathe) is used to illustrate as an example
throughout this tutorial. The relational schema shows below in accordance with the Figure 5.5 in
the textbook.
Relational Schema
EMPLOYEE
Fname Minit
Lname Ssn Bdate Address Sex Salary Super_ssn Dno
DEPARTMENT
Dname Dnumber Mgr_ssn Mgr_start_date
DEPT_LOCATIONS
Dnumber Dlocation
PROJECT
Pname Pnumber Plocation Dnum
WORKS_ON
Essn Pno Hours
DEPENDENT
Essn Depentdent_name Sex Bdate Relationship
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18

Partial preview of the text

Download Database Design using Microsoft Access: A Step-by-Step Guide and more Study Guides, Projects, Research Innovation in PDF only on Docsity!

CS 4700/6700 A Sample of Small Database Design Using Microsoft Access (2019)

Company relational database schema from the textbook (Fundamentals of Database systems, 7th Edition, by Ramez Elmasri and Shamkant Navathe) is used to illustrate as an example throughout this tutorial. The relational schema shows below in accordance with the Figure 5.5 in the textbook.

Relational Schema

EMPLOYEE

Fname Minit Lname Ssn Bdate Address Sex Salary Super_ssn Dno

DEPARTMENT

Dname Dnumber Mgr_ssn Mgr_start_date

DEPT_LOCATIONS

Dnumber Dlocation

PROJECT

Pname Pnumber Plocation Dnum

WORKS_ON

Essn Pno Hours

DEPENDENT

Essn Depentdent_name Sex Bdate Relationship

1. Creating a New Database

When you open Microsoft Access 2019 it should look like Figure 1. To create a new database, you can choose “Blank database”.

Figure 1

Type the name of the database in File Name box of the pop-up window. To save the database at a different location, click on the highlighted folder symbol. Once the database name is entered, click on the “Create” button. Here the database is named “Company” as shown in Figure 2.

2. Creating New Tables

Click “Create” first, then in the sub tab, click on “Table”. Figure 4 shows how it should appear when you do the above. Actually, Table 1 is created by default before you create a new table.

Figure 4

Now under the tab “Home” or tab “Fields”, click on “View” and select “Design View”. Then, in the pop-up window as shown in Figure 5, type the table name and click “OK”. Here, “EMPLOYEE” is entered as the table name.

Once you click “OK” in previous step, you can start entering the attribute (aka field) names and specify the data type from the drop-down menu as shown in Figure 6. By default, it sets the first attribute you entered as the primary key. To mark or unmark any of the attributes as the primary key, click on the highlighted “Primary Key” symbol.

In the encircled area shown in Figure 8, constrains can be made on the input data of attributes. For example, in Figure 8, the “Field Size” of “Sex” is set to be 1. And the “Validation Rule” is set to be “M or F or U”, which means that the input of attribute “Sex” can only be “M”, “F” or “U” for unknown. When the input data are invalid, the message in “Validation Text” will be popped up to remind users.

After inputting all the attribute names of a table and their data types, click on “View” and select “Datasheet View”.

Once “Yes” is selected, a datasheet appears as in Figure 11. Here you can start entering data row by row in the EMPLOYEE table.

Repeat all the steps of “Creating New Tables”, in order to create all other tables in your database. And the completed database looks like Figure 12. Input data comes from the Figure 5.6 in the textbook.

When “Relationships” is clicked, the “Show Table” window opens, as in Figure 14. Alternatively, you can open the “Show Table” by clicking on the highlighted symbol.

Figure 14

In the “Show Table”, select all tables you want to establish relationships then click the “Add” button at the lower part. These tables will appear on the background board as shown in Figure

  1. Once you have finished adding tables, click on the “X” or “Close” buttons to close the “Show Table”.

Figure 15

The referential integrity constraint between two relations can be specified by dragging the primary key attribute of one table (e.g., “Ssn” in the EMPLOYEE table) to the foreign key attribute of the other table (e.g., “Essn” in the WORKS_ON table). Then “Edit Relationships” window appears like Figure 16. Make sure that the relationship is made between appropriate attributes by checking the attribute and table names in the “Table/Query” and “Related Table /Query”. Sometimes, by dragging operations, unrelated attributes may be connected incorrectly, so always check the attribute names before clicking on “Create”. Once you click on “Create”, a line connecting these two attributes will appear as shown in Figure 17.

generated like table “EMPLOYEE_1” in Figure 18. Moreover, when there is more than one relationship between two tables, like “EMPLOYEE” and “DEPARTMENT”, then a copy of one of the tables also needs to be created. And the copy table is still “EMPLOYEE_1” in this more than one relationship situation. To do so, press “No” at the dialogue window asking to modify an existing one.

Figure 18

To exit from “Relationship Tools”, click on any of the encircled areas in Figure 19. A dialogue box asking “Do you want to save changes to the layout of ‘relationships’?” appears. Click on ‘Yes’.

4. Writing Queries

To start writing queries, click on “Create” then “Query Design”.

Now click on “SQL View” then select “SQL SQL View”.

Figure 22

Once ‘SQL SQL View’ is selected, Figure 23 appears. SQL queries can be written on the provided space as shown below. To run the query, click the “! run” button.

Some sample queries are used for illustration. Query 1: Retrieve the name and address of all employees who work for the ‘Research’ Department.