Database Note

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 11

ACCESS DATABASE

Microsoft Access is a database management program for storing, organizing, retrieving,


updating, deleting and maintaining data or information in an effective manner.

A database is a collection of data in a definite format. Database objects are tools used to store
and work with data in a database. Examples of database tools are tables, query, form, report,
macros, module, etc.

Table is a storage container that keeps data in a row and column format. It can contain different
types of data such as texts, numbers, pictures, sound, date, etc.

Query is a command that retrieves data from a table based on a specified criterion. Example, data
on only student girls in house 3; data on students above 17years only, etc.

Form is a graphical interface used for data entry based on an underlying table or query, and it is
used to add, modify and delete data from a table.

Report is a screen output of data that is arranged in an order specified by the user.

Macro is a tool that allows you to automate certain actions in the application that are used
frequently. E.g. OnClick event button added to a form.

Module is a code written in Microsoft Visual basic Programing language to automate certain
functions that can be based on database objects. E.g. is a function to check and delete a multiple
record entry in a table.

A relation is defined as a set of tuples (records) that have the same attributes. To set a
relationship between two tables, you need to match the data in the fields that are common to both
tables.

Field is a category of data value represented by a column or cell in a table pertaining to all tuples
(records).

Record (Tuple) is a single set of data value pertaining one person or entity.

Value is an item of data entered as a record in a table. E.g. OrderID, 150 is a value.

Relational database stores data or information in multiple/many interrelated tables with each
table storing a particular category of information. Relational database can access these tables and
extract, reorganize and display the information contained within them in different ways without
changing the structure of the original tables.

In a table, tuples are represented by using rows and attributes are represented by using columns.

1
Gallery is a repository/collection of elements of the same category which acts as a central
location for accessing various styles and appearance settings for an object to provide a set of
visual choices to enhance the look and feel of database elements.

Thorough planning ensures that no data is missing or redundant and saves time when carrying
out future modifications on the database. To plan and design a database, you must determine:

 The purpose of the database


 The number of tables and type of information you will store in each table
 The fields that will be stored in each table
 The type of queries that you will want to perform on the database
 The forms that you will need to create
 The type of reports that you will need to generate

OR

 Identify the purpose of the database


 Reviewing the existing database
 Marking the preliminary list of fields
 Organizing the field into tables
 Providing sample data, retrieving of possible data maintenance problems, and revising
the table design as necessary
 Designating primary and foreign keys that can be used to relate to the tables
 Determining table relationships

A primary key is a field that uniquely identifies each record in a table. A primary key that is
formed as a combination of two or more fields that uniquely identifies a record/tuple is called, a
composite key/ a concatenate key/ compound key. It does not allow duplicate values.

A primary key field that is referenced in another table is called a foreign key.

Data type is used to store different types of data values in a column of a table to control the type
of data that a field stores such as integers, text, currency, memo, date/time, etc.

Text is a data type that stores numbers, text, symbols, alphabets or combination of both. It stores
up to a maximum of 255 characters.

Memo stores large number of texts and numeric characters.

Number is used to store numeric data for arithmetic calculations. It can hold up to 16bytes of
data.

Date/Time stores values of date and time between the years 100 through to 9999.

2
Currency is used to store currency or money values such as the price of products, numeric data as
8bytes with precision to 4 decimal places.

Auto number contains a unique value created automatically to be used as a primary key.

Yes/No stores Boolean values such as Yes/No, true/False, On/Off, 0 and 1.

OLE Object stores up images from Microsoft based programs. It stores up to 2GB of data

Hyperlink is used to store web addresses up to 1 GB.

Attachment is used to attach images, spreadsheet files, documents, charts and other types of
supported files to database records.

Database Views.

Datasheet view is the default view that displays records in a table.

Design view displays all fields with their data types and descriptions. This view does not display
table records/tuples.

Performing operations on tables.

Access enables you to perform the following operations on a table:

 Insert a field into a table


 Set a field as a primary key
 Enter data into a table
 Navigate through a table
 Modify field properties
 Set validation rules
 Move columns is a table
 Change the width of a column
 Delete records from a table
 Delete a table

Modifying field properties

Access enables you to set different properties for each field in a table. The field properties are
based on the data type of a field which can be modified in the design view. The following are
some examples of the field properties.

Field size: It is used to set the maximum size for the data stored in a field

Format: It species the manner in which data is displayed. E.g., the UnitPrice field property can be
formatted to currency to enable it to display a dollar sign ($) in the field.

3
Input Mask: It is used to simplify the task of data entry and control the values that users enter for
a field. E.g. you can create an input mask for the Phone Number field that specifies how to enter
a new phone number, with the format such as (024)-057-657. It is also set to hide password
records entered in a field to display either *********** or xxxxxxxxxxxxx.

Caption: It specifies a label for a field

Default value: it specifies a value that is automatically entered in a field when a new row is
added to a table.

Validation Rule: The expression builder dialog box is used to create an expression that enables
you to set different validation rules for a field. E.g. you can ensure that the e-mail address of
your customer should always be entered in “*@*.*” format where “*@”.*” means the e-mail
address field should contain data that has some text followed by the ‘@’ sign, followed by some
text, followed by a dot (.) and then with a text. Also, date field can also be set in the year 2020
by specifying the validation rule, >=#1/1/2020# AND <#1/1/2021#, and currency as
“$0,000,000” to limit the values that can be entered in the field.

The expression builder dialog box has three sections. These are the expression box, operator
buttons and the expression elements.

A. The expression box section is used to type and view expressions of the validation rule.
B. The operator buttons section contains the following type of operator buttons:
 Arithmetic operators are used to perform mathematical operations. The following list
describes various arithmetic operators:
i. +: add one value to another. E.g. value1 + value2.
ii. -: subtracts one value from another. E.g. value1 – value2.
iii. *: multiplies two values. E.g. value1 * value2.
iv. /: divides two values. E.g. value1 / value2.
 Comparison operators are used to compare two values. The following list describes the
comparison operators:
i. =: checks whether one value is equal to another value.
ii. <: checks whether one value is less than another value.
iii. <=: checks whether one value is less than or equal to another value.
iv. >: checks whether one value is greater than another value.
v. >=: checks whether one value is greater than or equal to another value.
vi. <>: checks whether two values are not equal to each other.
vii. Between And operator: checks whether one value lies between two given values.
E.g. between 6/1/2005 and 10/31/2005.
viii. Is Null: checks whether a value is null.

4
 Logical operators are used to test for the truth value of complex condition. A complex
condition consists of two or more conditions. The following list describes the logical
operators:
1. AND: The logical AND of two conditions returns true if both conditions are true.
E.g. >5 AND <> 100. The result would be true for values such as 6.27, and 104
but false for values such as 4 and 100.
2. OR: The logical OR of two conditions returns true if either condition is true. E.g.
<5 OR >500. The result would be true for values such as 4 and 511 but false for
values such as 7nand 386.
3. NOT: The logical NOT of a condition is true if the condition is false. E.g. NOT
between 100 And 200. The result will be true for values such as 87 and 212 but
false for values such as 117 and 189.
C. Expression Element section is further divided into three columns. The first column
displays folders that contain the main categories of expression elements. On double-
clicking a category, the sub-categories of the category are displayed in the second
column. On double-clicking a sub-category, the elements are displayed in the third
column. On double-clicking an element in the third column, the element is displayed in
the Expression box. If the selected element is a function, its arguments are displayed in
the lower-left corner of the Expression builder dialog box.

A relationship is an association set between common fields in two or more tables. OR. Table
relationships are defined as the representation of the association between data contained within
tables. Defining table relationships help you to retrieve records from related tables based on
identical fields. The identical fields are known as primary and foreign keys. There are three (3)
types of relationships. These are:

 One-to-one relationship exists between two tables where both the primary key and the
foreign keys are unique, such that one row of a table relates to exactly one row of
another table. The entity from which a relationship originates is the parent entity and the
other is the child entity. E.g. if in an organization, one department head manages one
department, a one-to-one relationship will exist between the two tables Department and
Department Head.
 One-to-many relationship exists between two tables where the primary key is unique, but
the foreign key allows duplicate data, such that one row of a table relates to more than
one row of another table. E.g. a class can have many students and, therefore, the class
and student tables have one-to-many relationship.
 Many-to-many relationship exists when more than one instance of a table relates to more
than one instance of another table. E.g. the customer and product table have a many-to-
many relationship because a customer can purchase many products and products can be
bought by many customers.

5
NB. Setting table relationships right at the start helps to ensure that the correct data is
stored across all the related tables in the database.

Referential integrity is the process that helps to ensure data validity across two tables. To
implement referential integrity, you must ensure that, the corresponding values of a foreign key
have a corresponding entry in the primary key field.

The elements of the find and replace dialog box helps one to perform a better search. These
elements are:

Find what combo box specifies the text to be located.

Look in drop-down list specifies whether the search location should include the column or the
entir table.

Match drop-down list restricts the scope of the search to a paet of the field, the beginning of the
field or the whole field

Search drop-down list specifies the direction in which the search should proceed.

Match case check box when selected, specifies whether the search has to be performed with the
same casing of the characters specified in the find what text box.

Search field as formatted check box finds the field values with input mask. It is automatically
selected when an input mask format is set for a table.

Find next button locates the next instance of the search criteria.

Cancel button stops the search and closes the find and replace dialog box.

Sorting data

Sorting is the method of organizing data in ascending or descending order of a particular field.

Filtering data

Filter is a set of criteria used to display a subset of records in a table. It is used to view a set of
records that satisfy a set of criteria

A Subdatasheet is a datasheet nested with another datasheet containing data related to the first
datasheet. Access automatically creates a Subdatasheet in a table which is in a one-to-one
relationship or is a part of one-to-many relationship.

Handling queries

6
Query is a command that retrieves data from a table based on a specified criterion. OR, Query is
a method that can be used to retrieve information from a database. The data that meets the
criteria of the query is displayed as the result of the query.

Types of queries

 Select query displays the result from one or more tables based on user-defined criteria. It
can be used to group records and calculate sums, counts and averages
 Crosstab query summarizes data for analysis. It is mainly used when you want
summarized values for both rows and columns. It enables you to calculate aggregates
such as sum, average, and count and summarizes the data for analysis. E.g. to find how
many products of each category were sold in each month.
 Update query can change data in existing tables. Therefore, it is used to make changes to
records in one or more tables. E.g. it is used for changing the price of a specific product
from $10 to $12.5.
 Append query adds a group of records extracted from one table at the end of another
table.
 Delete query is used to delete records that meet a specified criterion. It deletes a complete
record and not any specific field in a record.
 Make-table query creates a new table from a group of records extracted from other tables.
 Union query is used to view records from two tables with identical structure.
 Pass-Through query allows you to execute an SQL statement directly against tables in an
external database, such as oracle or SQL Server database. It does not create links to the
table or import data from external databases. Instead, it uses the Open Database
Connectivity (ODBC) connection to access the data in an external database.
 Data definition query creates or changes database objects in an Access, SQL Server, or
other server databases.
 Simple query enables you to select fields from multiple tables and queries.
 Find duplicate query enable you to find duplicate field values.
 Find unmatched query enables you to find records in a table with no related records in
another table.

NB: wizard is a tool that guides you through series of steps that helps to create a query, form or
report.

Query criterion is a search condition that is used in a query to retrieve or manipulate specific
information.

A calculated field is defined as a resultant field that derives its values from calculation performed
on other fields. Its value will change each time the expression changes.

Performing Calculations on Record Grouping

7
The following aggregate function can be used to group records in all databases:

 Sum option helps you to display the sum of all the numbers for a specified column.
 Average option helps you to display the average of all the numbers for a specified
column.
 Count option provides you the total number of values present in a specified column.
 Maximum option returns the largest numeric or alphabetic value for a specified column.
 Minimum option returns the smallest numeric or alphabetic value for a specified column.
 StDev option provides an estimate of the standard deviation of a set of values for a
specified column.
 Var option provides an estimate for the variance across the set of values in the column.
 First option returns the field value from the first record in the result of the query.
 Last option returns the field value from the last record in the result of the query.

Introducing forms

A table opened in a datasheet view displays all the records which can be overwhelming in case
the database contains a large number of records. Creating a customized access form allows you
to view and edit one record at a time which in turn will speed up the process of searching and
editing the records.

Forms are database objects that make it easy to insert, modify and delete records in a table
through a user-friendly interface. It is a graphical interface used for data entry. The following are
tools used for form creation:

Form tool creates a form that displays the fields in a table.

Form design tool helps you to create a form in design view.

Split form tool enables you to view the form in form view and datasheet view simultaneously.

Multiple items tool lets you view multiple records from the table in the form of a spreadsheet.

Pivot chart tool helps you to create a form in pivot chart view.

Blank form tool aids you in creating an empty/blank form which can be used to build a form
from scratch by adding and positioning controls according to your choice.

Using form wizard

A form wizard is defined as a tool that takes you through a step-by-step process of creating a
form. The following are the four main types of form layouts:

 Columnar
 Tabular

8
 Datasheet
 Justified

Viewing data by using an access form

Access allows database users to view forms I different ways such as during design, runtime, or a
combination of both. The different types of form views are:

o Design is a static view that gives a detailed view of the form structure. In addition, this
view consists of form header, detail and form footer section.
o Form is a dynamic view that helps you to view data from a table or a query on which the
form is based.
o Layout is an interactive and dynamic view and it helps you to make any changes in the
form. It combines the properties of form view and design view.

When a view is selected, the following tabs are enabled:

 Format tab get enabled when you open a form in the layout view
 Design tab get enabled when you open a form in the design view
 Arrange tab is enabled when you open a form either in design or in layout view

Using Controls

A form comprises of controls that are used to display data or perform specific actions in a form
such as adding or deleting a record from a table. The controls are used to display data, obtain
user input, perform an action or enhance the user interface. Based on the properties and
functionality, controls are divided into the following three categories:

 Bound controls are linked to a field in a table. You can use bound controls to display a
value, accept a value, or modify the value of a field in a table. E.g. combo box, text box
and list box are all bound controls.
 Unbound controls are not linked to the fields in a table. They are used to enhance the
appearance of a form or display information that is not linked to the fields in a table. E.g.
label control is an unbound control.
 Calculated controls are used to display a calculated value based on one or more fields in a
table. E.g. if you want to display 2 percent tax paid on a transaction of $600, you can use
a calculated control such as a text box control to display the tax value automatically.

Some of the commonly used form controls used either as bound or unbound controls are:

 Textbox is a bound control is used to display data linked to a field in a table. If you
display a calculated value in a text box control, it becomes a calculated control.
 Option button is a bound control used to display a field that has a Yes/No data type. Upon
selection, a Yes value is stored in a table, but no selection stores a No value in a table
9
 Label is unbound control used to display text such as titles and captions. A label control
can also be attached to another control. E.g. a label control can be attached to a Text Box
control to display the caption of the Text Box control.
 Check box is a bound control used to display a field that has a Yes/No data type. If you
select this control, a Yes value is stored. Alternatively, a No value is stored.
 Image in unbound control that enables you to add an image to a form.
 Combo box is a bound control used to display a drop-down list of values from an
underlying table. It enables you to type a value or select a value from a drop-down list.
 List box is a bound control used to display a drop-down list of values from an underlying
table. It enables you to only select a value from the list and does not allow you to type a
value unlike a combo box.
 Button is unbound control used to perform actions such as adding a record, deleting a
record, or opening a table.

Introduction to reports

A report is a screen output of data that is arranged in an order specified by user. Access reports
are used for presenting data in tables and queries in a structured format. They can be used to
represent data in a printed format or can be saved as a web page.

Using report creation tools

Reports can be created by using one of the following report creation tools:

 Report tool creates a report that uses all the fields in a table or a query and the report will
be displayed in layout view.
 Blank report tool helps you to create a blank report from scratch by adding and
positioning controls according to your choice.
 Report design tool helps to create a report in a design view.
 Report wizard tool helps you to create a report by following a step-by-step guided
approach.

Viewing Reports

The following are the four views to edit and modify reports:

o Design view provides you with an outline of the structure of your report.
o Report view is a dynamic view that allows you to view a data from a table or query on
which the report is based.
o Layout view is an interactive and dynamic view that you can use to create a report.
o Print preview is used to check how your report may look when printed on paper.

The following tabs are enabled during report creation and design:

10
a. Format tab gets enabled when a report is opened in layout view.
b. Arrange tab gets enabled when a report is opened in either design or layout view.
c. Page set up tab gets enabled in both the design and design views.
d. Design tab gets enabled when a report is opened in a design view.
e. Print preview tab gets enabled when you select the print preview view.

11

You might also like