You are on page 1of 25

Table of Contents

1 Case Study...................................................................................................................... 3

2 Identify Entities ................................................................................................................ 3

2.1 Entity............................................................................................................................ 3
3 Design Relationships ....................................................................................................... 3

4 Remove many to many relationships and identify foreign keys and primary keys ............ 4

4.1 Attributes of tables with Primary Keys and Foreign Keys. ............................................ 5
4.2 What is a query? .......................................................................................................... 6
4.3 What is a form?............................................................................................................ 6
4.4 What is a report? ......................................................................................................... 6
4.5 What is a navigation form?........................................................................................... 6
5 Getting Started with Tables, forms, Queries and Reports. ............................................... 7

5.1 Creating a database..................................................................................................... 7
5.2 Create a blank database .............................................................................................. 8
6 Creating Tables ............................................................................................................... 8

6.1 Add a table .................................................................................................................. 8
6.1.1 Create a table, starting in Datasheet view ............................................................. 9
6.1.2 Create a table, starting in Design view .................................................................. 9
6.2 Understanding Data Types .........................................................................................11
6.3 Field Properties...........................................................................................................12
6.4 Working with relationships ..........................................................................................13
6.4.1 Primary Key and Foreign Key ..............................................................................13
6.4.2 Set the primary key using fields you already have in Access ...............................13
6.4.3 Creating relationships ..........................................................................................13
6.4.4 Enforce Referential integrity .................................................................................14
7 Creating Forms...............................................................................................................16

7.1 Choose a form tool......................................................................................................16
7.2 Create a form from an existing table or query in Access .............................................16
7.3 Create a blank form in Access ....................................................................................16

1
7.4 Create a split form in Access ......................................................................................17
8 Creating Queries ............................................................................................................19

8.1 Use Query Wizard to create query ..............................................................................19
8.1.1 Launch the Query Wizard ....................................................................................19
8.1.2 Save the query giving a proper name. .................................................................20
8.1.3 Now you can view the result as below..................................................................20
9 Creating Reports ............................................................................................................21

9.1 Choose a record source ..............................................................................................21
9.2 Choose a report tool ...................................................................................................21
9.3 Create the report .........................................................................................................22
10 Create Navigation Form .................................................................................................24

10.1 What is a navigation Form ..........................................................................................24
10.2 How to create a navigation form..................................................................................24

2
1 Case Study

Suppose you have to design a database for 1st year students of the Management Faculty of the
University. The faculty consists of several departments that offer courses for registered
students. One department can offer more than one course. Faculty also records details about
lecturers who belong to departments. A lecturer is assigned to one or more courses. A Student
belongs to only one department and can follow one or many Courses. (Note: Grade is not
considered in this scenario)

2 Identify Entities
2.1 Entity
An entity is a person, place, thing, event, or concept of interest to the business or organization
about which data is likely to be kept.

ex: - Student, Lecturer, Course, Department

3 Design Relationships
There are 3 types of relationships

1. One-to-One Relationships
2. One-to-Many Relationships
3. Many-to-Many Relationships.

According to this case study it has following relationships

Department Lecturer Course Student

Department Has Offers

Lecturer Belongs to Conducts

Course Offered by Conducted by Taken by

Student Takes

3
Belongs to Has
Student Department Lecturer

b y
T ak ed
uct

Offers
en b
y
C ond

Course

4 Remove many to many relationships and identify foreign keys
and primary keys
Since this has many to many relationships we have to remove them. In order to remove many to
many relationships we have to introduce associate entities. There are two types of many to
many relationships in this case.

1. Relationship between student and course
2. Relationship between lecturer and course

Therefore we can introduce following associate entities. Associate entity should contain the key
columns (Primary Key) of other two entities.

1. course_student
2. course_lecturer

After introducing associate entities the diagram should be as follows.

student belongs to department has lecturer
conducts
takes

course_Student offers course handle by course_lecturer

Above entities can be considered as the tables according to this scenario. Those tables are
linked with Primary Keys and Foreign key.

• A primary key is a special relational database table column (or combination of columns)
designated to uniquely identify all table records.
• A foreign key is a field (or collection of fields) in one table that uniquely identifies a row of
another table.

4
4.1 Attributes of tables with Primary Keys and Foreign Keys.
Student

• regNo(PK) • dob
• sFirstName • admission_Date
• sLastName • gender
• address • deptId(FK)
• contactNo
Lecturer

• lecId(PK)
• lFirstName
• lLastName
• deptId(FK)

Department

• deptId(PK)
• deptName
• headName
• location
• startDate

Course

• courseCode(PK)
• courseTitle
• credit
• deptId(FK)

Course_Student

• regNo(PK,FK)
• courseCode(PK,FK)
• marks
• semester

Course_Lecturer

• courseCode(PK,FK)
• lecId(PK,FK)
• venue
• lectureTime

5
4.2 What is a query?
A query is a request for data or information from a database table or combination of
tables.

Ex: - Create a query that displays regNo, sFirstname, sLastname, gender, contactNo,
address, and dob of the Students.

4.3 What is a form?
A form is a window or screen that contains numerous fields, or spaces to enter data. Each
field holds a field label so that any user who views the form gets an idea of its contents.
A form is more user-friendly than generating queries to insert data into table fields.

4.4 What is a report?
A database report is the formatted result of database queries and contains useful data for
decision-making and analysis.

4.5 What is a navigation form?
Access includes a Navigation Control that makes it easy to switch between the various
forms and reports in your database. A navigation form is simply a form that contains a
Navigation Control. Navigation forms are a great addition to any desktop database

.

6
5 Getting Started with Tables, forms, Queries and Reports.
When you first start Access, or if you close a database without closing Access, Microsoft Office
Backstage view is displayed.

5.1 Creating a database
When you open Access, Backstage view displays the New tab. The New tab provides several
ways that you can create a new database:

• A blank database - You can start from scratch if you want. This is a good option if you
have very specific design requirements or have existing data that you need to
accommodate or incorporate.
• A template that is installed with Access - Consider using a template if you are starting
a new project and would like a head start. Access comes with several templates
installed by default.
• A template from Office.com - In addition to the templates that come with Access, you
can find many more templates on Office.com. You don't even have to open a browser,
the templates are available from the New tab.

7
5.2 Create a blank database
1. On the File tab, click New, and then click Blank Database.
2. Type a file name in the File Name box. To change the location of the file from the

default, click Browse for a location to put your database (next to the File Name box),
browse to the new location, and then click OK.
3. Click Create.
Access creates the database with an empty table named Table1, and then opens Table1
in Datasheet view. The cursor is placed in the first empty cell in the Click to Add column.

4. Begin typing to add data, or you can paste data from another source

6 Creating Tables
6.1 Add a table
You can add new tables to an existing database by using the commands in the Tables group on
the Create tab.

8
6.1.1 Create a table, starting in Datasheet view
In Datasheet view, you can enter data immediately and let Access build the table structure
behind the scenes. Field names are assigned numerically (Field1, Field2, and so on), and
Access automatically sets each field's data type, based on the data you enter.

1. On the Create tab, in the Tables group, click Table.
Access creates the table and selects the first empty cell in the Click to Add column.
2. On the Fields tab, in the Add & Delete group, click the type of field that you want to add.

If you don't see the type that you want, click More Fields
3. Access displays a list of commonly used field types. Click the field type that you want,
and Access adds the new field to the datasheet at the insertion point.
You can move the field by dragging it. When you drag a field in a datasheet, a vertical
insertion bar appears where the field will be placed.
4. To add data, begin typing in the first empty cell, or paste data from another source, as
described in the section Copy data from another source into an Access table.
5. To rename a column (field), double-click the column heading, and then type the new
name.
You should give a meaningful name to each field, so that you can tell what it contains
when you see it in the Field List pane.
6. To move a column, click its heading to select the column, and then drag the column to
the location that you want. You can also select multiple contiguous columns and then
drag them to a new location all at once. To select multiple contiguous columns, click the
column header of the first column, and then, while holding down SHIFT, click the column
header of the last column.

6.1.2 Create a table, starting in Design view
In Design view, you first create the table structure. You then switch to Datasheet view to enter
data, or enter data by using some other method, such as pasting, or importing.

1. On the Create tab, in the Tables group, click Table Design.
2. For each field in your table, type a name in the Field Name column, and then select a
data type from the Data Type list.
3. If you want, you can type a description for each field in the Description column. The
description is then displayed on the status bar when the cursor is in that field in
Datasheet view. The description is also used as the status bar text for any controls in a

9
form or report that you create by dragging the field from the Field List pane, and for any
controls that are created for that field when you use the Form Wizard or Report Wizard.
4. After you have added all your fields, save the table:
On the File tab, click Save.
5. You can begin typing data in the table at any time by switching to Datasheet view and
clicking in the first empty cell. You can also paste data from another source

More Details: https://support.office.com/en-us/article/Create-a-new-database-32a1ea1c-
a155-43d6-aa00-f08cd1a8f01e

10
6.2 Understanding Data Types

7 Data Type 8 Usage
Short Text (formerly known as “Text”) Alphanumeric data (names, titles, etc.)

Long Text (formerly known as “Memo” Large amounts of alphanumeric data: sentences
and paragraphs.
Number Numeric data.
Large Number Numeric data.

Date/Time Dates and times.
Currency Monetary data, stored with 4 decimal places of
precision.
AutoNumber Unique value generated by Access for each new
record.
Yes/No Boolean (true/false) data; Access stores the
numeric value zero (0) for false, and -1 for true.
OLE Object Pictures, graphs, or other ActiveX objects from
another Windows-based application.
Hyperlink A link address to a document or file on the
Internet, on an intranet, on a local area network
(LAN), or on your local computer
Attachment You can attach files such as pictures, documents,
spreadsheets, or charts; each Attachment field
can contain an unlimited number of attachments
per record, up to the storage limit of the size of a
database file. Note, the Attachment data type isn't
available in MDB file formats.
Calculated You can create an expression that uses data from
one or more fields. You can designate different
result data types from the expression. Note, the
Calculated data type isn't available in MDB file
formats.
Lookup Wizard The Lookup Wizard entry in the Data Type column
in Design view is not actually a data type. When
you choose this entry, a wizard starts to help you
define either a simple or complex lookup field. A
simple lookup field uses the contents of another
table or a value list to validate the contents of a
single value per row. A complex lookup field
allows you to store multiple values of the same
data type in each row.

More Details: https://support.office.com/en-us/article/Data-types-for-Access-desktop-databases-
df2b83ba-cef6-436d-b679-3418f622e482

11
8.1 Field Properties
Item Description

Field Size For Text fields, this property sets the maximum
number of characters that can be stored in the
field. The maximum is 255. For Number fields, this
property sets the type of number that will be
stored (Long Integer, Double, and so on). For the
most efficient data storage, it is recommended
that you allocate the least amount of space that
you think you will need for the data. You can
adjust the value upwards later, if your needs
change.
Format This property sets how the data is displayed. It
does not affect the actual data as it is stored in the
field. You can select a predefined format or enter
a custom format.
Decimal Places Set the number of decimal places to show a
numeric field
Input Mask Use this property to specify a pattern for all data
that will be entered in this field. This helps ensure
that all data is entered correctly, and that it
contains the required number of characters. For
help about building an input mask, click Builder
button at the right side of the property box.
Caption If the user want a different name to appear for the
column header in the datasheet view or the label
in form view. (eg: You can use Department ID to
describe dept id)
Default Value Use this property to specify the default value that
will appear in this field each time that a new
record is added. For example, if you have a
Date/Time field in which you always want to
record the date that the record was added, you
can enter "Date()" (without the quotation marks)
as the default value.
Validation Rule Can be used to validate the information that the
user enters (eg: enter a value less than 10)
Validation Text Allow user to set the message that appears if the
validation rule fails.
Required This property sets whether a value is required in
this field. If you set this property to Yes, Access
does not allow you to add a new record unless a
value is entered for this field.
More Details: https://support.office.com/en-us/article/Create-a-new-database-32a1ea1c-a155-
43d6-aa00-f08cd1a8f01e

12
8.2 Working with relationships
8.2.1 Primary Key and Foreign Key
A primary key is a field or set of fields with values that are unique throughout a table. Access
can automatically create a primary key field for you when you create a table, or you can specify
the fields that you want to use as the primary key. This topic explains how and why to use
primary keys.

Access uses primary key fields to quickly associate data from multiple tables and combine that
data in a meaningful way. You can include the primary key fields in other tables to refer to the
table that is the source of the primary key. In those other tables, the fields are called foreign
keys. For example, a Dept ID field in the Department table might also appear in the Student
table. In the Department table, it is the primary key. In the Student table, it is called a foreign
key. A foreign key, simply stated, is another table's primary key.

8.2.2 Set the primary key using fields you already have in Access
For a primary key to work well, the field must uniquely identify each row, never contain an empty
or null value, and rarely (ideally, never) change. To set the primary key:

1. Open the database that you want to modify.
2. In the Navigation Pane, right click the table in which you want to set the primary key
and, on the shortcut menu, click Design View.
3. Select the field or fields that you want to use as the primary key.
To select one field, click the row selector for the field you want.
To select more than one field to create a composite key, hold down CTRL and then
click the row selector for each field.
4. On the Design tab, in the Tools group, click Primary Key.

A key indicator is added to the left of the field or fields that you specify as the primary
key.

8.2.3 Creating relationships
1. On the Database Tools tab, in the Relationships group, click Relationships.

13
2. If you haven't yet defined any relationships, the Show Table dialog box automatically
appears. If it doesn't appear, on the Design tab, in the Relationships group, click Show
Table.
The Show Table dialog box displays all the tables and queries in the database. To see
only tables, click Tables.

3. Select one or more tables, and then click Add. After you have finished adding tables,
click Close.
4. Drag a field (typically the primary key) from one table to the common field (the foreign
key) in the other table. To drag multiple fields, press the Ctrl key, click each field, and
then drag them.

The Edit Relationships dialog box appears.

8.2.4 Enforce Referential integrity
Referential integrity means that the foreign key in any referencing table must always refer
to a valid row in the referenced table. Referential integrity ensures that the relationship
between two tables remains synchronized during updates and deletes

14
8.2.4.1 Cascade update related fields
For relationships that enforce referential integrity between tables, the updating of all
related records in the related table or tables when a record in the primary table is
changed. If you select the Cascade Update Related Fields check box when defining a
relationship, any time you change the primary key of a record in the primary table,
Microsoft Access automatically updates the primary key to the new value in all related
records.

8.2.4.2 Cascade delete related records
For relationships that enforce referential integrity between tables, the deletion of all related
records in the related table or tables when a record in the primary table is deleted. If you
select the Cascade Delete Related Records check box when defining a relationship, any
time you delete records in the primary table, Microsoft Access automatically deletes
related records in the related table.

5. Verify that the field names shown are the common fields for the relationship. If a field
name is incorrect, click on the field name and select the appropriate field from the list.
6. To enforce referential integrity for this relationship, select the Enforce Referential
Integrity box.
7. Click Create.
8. When you are finished in the Relationships window, click Save to save your
relationship layout changes.

More Details: https://support.office.com/en-us/article/Tables-0d51ea2b-c8ae-45c4-a4ab-789c
0f608b97?ui=en-US&rs=en-US&ad=US

15
9 Creating Forms
9.1 Choose a form tool
The form tools are located on the Create tab of the ribbon, in the Forms group. The following
table describes the options:

Tool Description
Form You can use the Form tool to quickly create a single item form. This type of form
displays information about one record at a time
Form Create new blank form in design view. In design view, you can make advanced
Design design changes to forms, such as adding custom control types and writing codes.
Blank If the other form tools do not fit your needs, you can use the Blank Form tool instead.
Form As the name implies, this tool opens a new, blank form, which you can then
customize and format the way you want. This can be a very quick way to build a
form, especially if you plan to put only a few fields on the form.
Form If you want to be more selective about what fields appear on the form, you can use
Wizard the Form Wizard instead. The wizard also lets you define how the data is grouped
and sorted, and you can use fields from more than one table or query

9.2 Create a form from an existing table or query in Access
To create a form from a table or query in your database, in the Navigation Pane, click the table
or query that contains the data for your form, and on the Create tab, click Form.

Access creates a form and displays it in Layout view. You can make design changes like
adjusting the size of the text boxes to fit the data, if necessary.

9.3 Create a blank form in Access
1. To create a form with no controls or preformatted elements: On the Create tab, click
Blank Form. Access opens a blank form in Layout view, and displays the Field List pane.
2. In the Field List pane, click the plus sign (+) next to the table or tables that contain the
fields that you want to see on the form.

16
3. To add a field to the form, double-click it or drag it onto the form. To add several fields at
once, hold down CTRL and click several fields, and then drag them onto the form at the
same time.

4. Use the tools in the Controls group on the Form Layout Tools tab to add a logo, title,
page numbers, or the date and time to the form.
5. If you want to add a wider variety of controls to the form, click Design and use the tools
in the Controls group.

9.4 Create a split form in Access
A split form gives you two views of the data at the same time — a Form view and a Datasheet
view. Working with split forms gives you the benefits of both types of forms in a single form. For
example, you can use the datasheet portion of the form to quickly locate a record, and then use
the form portion to view or edit the record. The two views are connected to the same data
source and are synchronized with each other always.

17
To create a new split form by using the Split Form tool, in the Navigation Pane, click the table or
query that contains the data, and then on the Create tab, click More Forms, and then click Split
Form. Access creates the form and you can make design changes to the form. For example,
you can adjust the size of the text boxes to fit the data, if necessary.

More Details: https://support.office.com/en-us/article/Introduction-to-forms-e8d47343-c937-
44e8-a80f-b6a83a1fa3ae

18
10 Creating Queries

10.1 Use Query Wizard to create query
10.1.1 Launch the Query Wizard
Click Query Wizard from the Create tab on the Ribbon. The New Query dialog box will appear.
Click Ok button.

Simple query wizard dialog box will appear. Select the table from Tables/Queries. In here select
Course table and select fields you need to insert to the query from Available Fields box to
Selected fields box.

19
10.1.2 Save the query giving a proper name.

10.1.3 Now you can view the result as below.

More Details: https://support.office.com/en-us/article/Introduction-to-queries-a9739a09-d3ff-
4f36-8ac3-5760249fb65c

20
11 Creating Reports

11.1 Choose a record source
The record source of a report can be a table, a named query, or an embedded
query. The record source must contain all the rows and columns of data you
want display on the report.
• If the data is from an existing table or query, select the table or query in the
Navigation Pane, and then continue to Step 2.
• If the record source does not yet exist, do one of the following:
• Continue to Step 2 and use the Blank Report tool,

Or

• Create the table(s) or query that contains the required data. Select the
query or table in the Navigation Pane, and then continue to Step 2.

11.2 Choose a report tool
The report tools are located on the Create tab of the ribbon, in the Reports group. The following
table describes the options:

Tool Description
Report Creates a simple, tabular report containing all of the fields in the record source you
selected in the Navigation Pane.
Report Opens a blank report in Design view, to which you can add the required fields and
Design controls.
Blank Opens a blank report in Layout view, and displays the Field List from where you
Report can add fields to the report
Report Displays a multiple-step wizard that lets you specify fields, grouping/sorting levels,
Wizard and layout options.
Labels Displays a wizard that lets you select standard or custom label sizes, as well as
which fields you want to display, and how you want them sorted.

21
11.3 Create the report
• Click the button for the tool you want to use. If a wizard appears,
follow the steps in the wizard and click Finish on the last page.

Access displays the report in Layout view.

• Format the report to achieve the looks that you want:
o Resize fields and labels by selecting them and then dragging the
edges until they are the size you want.
o Move a field by selecting it (and its label, if present), and then
dragging it to the new location.
o Right-click a field and use the commands on the shortcut menu to
merge or split cells, delete or select fields, and perform other
formatting tasks.
o In addition, you can use the features described in the following
sections to make your report more attractive and readable.

Design View of Report

22
Report View

More Details: https://support.office.com/en-us/article/Introduction-to-reports-in-Access-
e0869f59-7536-4d19-8e05-7158dcd3681c

23
12 Create Navigation Form

12.1 What is a navigation Form?
Access 2016 provides several layouts for Navigation forms; which one you choose depends on
what you need done. A Navigation form helps end users to open forms and run reports in a
database without needing a lot of Access knowledge. Here’s how you build a Navigation form.

12.2 How to create a navigation form
i. Open the database file that will contain the Navigation form and click the Create tab on
the Ribbon. The Forms group appears toward the center of the Ribbon.

ii. Click the Navigation button on the right side of the Forms group. A drop-down list of
Navigation layouts appears.

iii. Select a layout from the drop-down list. The selected Navigation form appears in Layout
view, ready for design. Your database objects appear.

24
iv. From the Navigation pane, drag an object that you want your users to open on top of an
[Add New] tab on the Navigation form. The object’s name appears in place of the Add
New tab; the object itself appears in the middle of the form. Otherwise you can add
navigation buttons from controls under design tab and place the button on Add New tab.

Using Buttons

Using Tabs

v. Repeat Step 5 for each object you’d like added to the Navigation form. A new tab
appears on the form for each object you add. In Layout view, you can edit the tab name
by clicking on the name until a cursor appears.

vi. Click Save on the Quick Access Toolbar to save and name the form. The form appears
in the Navigation pane and is opened like any other form.

More Details: https://support.office.com/en-us/article/Create-a-navigation-form-32e50477-
3039-4503-9cd6-210a1a836007

25