Professional Documents
Culture Documents
1 Case Study...................................................................................................................... 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
1
7.4 Create a split form in Access ......................................................................................17
8 Creating Queries ............................................................................................................19
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.
3 Design Relationships
There are 3 types of relationships
1. One-to-One Relationships
2. One-to-Many Relationships
3. Many-to-Many Relationships.
Student Takes
3
Belongs to Has
Student Department Lecturer
b y
T ak ed
uct
Offers
en b
y
C ond
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
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.
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.
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.
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.
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
10
6.2 Understanding Data Types
Long Text (formerly known as Memo Large amounts of alphanumeric data: sentences
and paragraphs.
Number Numeric data.
Large Number Numeric data.
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:
A key indicator is added to the left of the field or fields that you specify as the primary
key.
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.
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.
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.
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
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.
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.
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.
18
10 Creating Queries
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.
20
11 Creating Reports
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.
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.
22
Report View
23
12 Create Navigation Form
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 objects 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 youd 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.
25