Database Management With MS Access: School of Management Studies
Database Management With MS Access: School of Management Studies
Submitted to:
Submitted by:
Ms. Sonam
Table of Contents
Database An Introduction
Database Hierarchy
Normalization
Creating a Database
Creating a Table
10
11
.
14
.
15
16
17
Freeze Pane
Creating Relationships
One to Many Relation
One to One Relationship
Queries
.
20
20
.
21
Simple Queries
21
Advanced Queries
23
.
24
24
26
Reports
Creating a Report Using Forms
Creating a Report Using Report Wizard
28
.
28
Database An Introduction
Database is basically a collection of information organized in such a way that the user can
quickly retrieve desired pieces of data. From the managerial point of view, organizations have
to store voluminous data and systematically process the stored data. As the organizations are
working in highly competitive and dynamic environment, the needs of the managers also
keep on changing. The managers need to dynamically store the process data, that is, they
have to analyse the stored data from different perspective before taking any decisions. Hence,
the storage and processing of data are very crucial aspects, which need special attention. It
must be clear from the discussion that organisations need special storage and retrieval facility
for information. To accomplish these objectives, they use the concept of database.
For managing this huge amount of data, organisations are now using various softwares
known as Database Management System (DBMS) which is a collection of programs that
enables the user to store, modify, and extract information from a database. There are many
different types of database management systems, ranging from small systems that run on
personal computers to huge systems that run on mainframes. Various DBMS tools such as
MS Access, Oracle and DB/2 are available in the market.
Database Hierarchy
Data hierarchy refers to the systematic organization of data, often in a hierarchical form. Data
organization involves fields, records, files and so on. A data field holds a single fact or
attribute of an entity. Consider a date field, e.g. "September 19, 2004". This can be treated as
a single date field (e.g. birthdate), or 3 fields, namely, month, day of month and year. The
hierarchy helps in storing the data in orderly manner, which helps in timely and accurate
retrieval of the information. The 5 level hierarchy model is the most widely used model.
Various components of the hierarchy model are discussed below.
Database: At the top of the hierarchy is the database, which stores data regarding various
specific entities, for example, the database of the organisation will store all important
information regarding the organisation.
File: A file is a collection of related records. If there are 100 employees, then each employee
would have a record (e.g. called Employee Personal Details record) and the collection of 100
such records would constitute a file (in this case, called Employee Personal Details file).
Record: A record is a collection of related fields. An Employee record may contain a name
field(s), address fields, birthdate field and so on.
Data item: it stores the specific values for specific records. For example, the file of the
employee has records of name and age. If we store name as John and age as 32, these are the
data items.
Bytes: At the lowest level of hierarchy is the byte, which is a collection of bits. Bits are the
binary digits, zero and one. A combination of bits is used to represent any character. The
databases are essentially computer based and the computer understands only the binary code.
Hence, it is important to store the data in the form of binary digits. The combination of bits
results in bytes and combination of bytes results in data items.
The figure shows a sample database hierarchy with various levels
Table: The table is a collection of related data entries and it consists of columns (fields) and
rows (records). It is a database object in which data is stored. Below is an example of a table
containing data of employees in an organisation.
Emp_
ID
Emp_Na
me
2 Peter
Emp_Designation
Senior Sales
Manager
Deputy Sales
Manager
3 Xaveir
4 Smith
CEO
Senior Vice
1 John
Emp_S
al
$
200000
$
150000
$
300000
$
Emp_D
ept
Sales
Sales
Executiv
e
Executiv
President
5 Mitchell
COO
250000
$
300000
e
Executiv
e
Record (Row): A record, also called a row of data, is each individual entry that exists in a
table. For example there are 5 records in the above EMPLOYEE table. Following is a single
row of data or record in the EMPLOYEE table.
1
John
Senior Sales
Manager
$
200000
Sales
Field (Column): Every table is broken up into smaller entities called fields. The fields in the
EMPLOYEE table consist of EMP_ID, EMP_NAME, EMP_DESIGNATION, EMP_SAL,
EMP_DEPT.
Emp_Na
me
John
Peter
Xaveir
Smith
Mitchell
SQL Constraints are the rules enforced on data columns on table. These are used to limit the
type of data that can go into a table. This ensures the accuracy and reliability of the data in
the database. Constraints could be column level or table level. Column level constraints are
applied only to one column whereas table level constraints are applied to the whole table.
Following are commonly used constraints available in SQL:
NOT NULL Constraint: Ensures that a column cannot have NULL value.
DEFAULT Constraint: Provides a default value for a column when none is specified.
UNIQUE Constraint: Ensures that all values in a column are different.
PRIMARY Key: Uniquely identified each rows/records in a database table.
FOREIGN Key: Uniquely identified a rows/records in any another database table.
CHECK Constraint: The CHECK constraint ensures that all values in a column satisfy
certain conditions.
INDEX: Use to create and retrieve data from the database very quickly.
Data integrity refers to maintaining and assuring the accuracy and consistency of data over its
entire life-cycle, and is a critical aspect to the design, implementation and usage of any
system which stores, processes, or retrieves data. The following categories of the data
integrity exist with each RDBMS:
Entity Integrity: There are no duplicate rows in a table.
Domain Integrity: Enforces valid entries for a given column by restricting the type, the
format, or the range of values.
Referential integrity: Rows cannot be deleted, which are used by other records.
User-Defined Integrity: Enforces some specific business rules that do not fall into entity,
domain or referential integrity.
Normalization
Database normalization is the process of organizing the attributes and tables of a relational
database to minimize data redundancy. Normalization involves refactoring a table into
smaller (and less redundant) tables but without losing information; defining foreign keys in
the old table referencing the primary keys of the new ones. The objective is to isolate data so
that additions, deletions, and modifications of an attribute can be made in just one table and
then propagated through the rest of the database using the defined foreign keys. Three forms
of normalization help to check redundancy in the databases.
Age
Subject
Adam
15
Biology, Maths
Alex
14
Maths
Stuart
17
Maths
In First Normal Form, any row must not have a column in which more than one value is
saved, like separated with commas. Rather than that, we must separate such data into multiple
rows. Student Table following 1NF will be as follows.
Student
Age
Subject
Adam
15
Biology
Adam
15
Maths
Alex
14
Maths
Stuart
17
Maths
The problem with using the First Normal Form is that the data redundancy increases, as there
will be many columns with same data in multiple rows but each row as a whole will be
unique.
Age
Adam
15
Alex
14
Stuart
17
Subject
Adam
Biology
Adam
Maths
Alex
Maths
Stuart
Maths
In Subject Table the candidate key will be {Student, Subject} column. Now, both the above
tables qualify for Second Normal Form and will never suffer from Update Anomalies.
Although there are a few complex cases in which table in Second Normal Form suffers
Update Anomalies, and to handle those scenarios Third Normal Form is there.
Student
_id
Student_n
ame
DO
B
Stre
et
Cit
y
Sta
te
Zi
p
In this table Student_id is Primary key, but street, city and state depends upon Zip. The
dependency between zip and other fields is called transitive dependency. Hence to
apply 3NF, we need to move the street, city and state to new table, with Zip as primary key.
New Student_Detail Table:
Student
_id
Student_na
me
DO
B
Zi
p
Address Table:
Zi
p
Stre
et
Ci
ty
Sta
te
Creating a Database
To create a blank database using MS Access, the following steps are to be performed:
1
2
3
4
Click on the blank Access database option button in the initial MS access dialog box.
Click the OK button, and a new database dialog box will be opened.
Specify the appropriate name in the file name text box and thenm click on create
button.
A created blank database will appear in the MS access window.
Creating a Table
Once a blank database has been created, the next step is to populate the database with objects
such as tables, forms and reports. Now we will see how to create a table. A table is useful in
storing huge amount of data with efficiency and convenience. The following steps need to be
performed in order to create a table
1
2
Click on the create option in the main menu bar in the database window.
The tables can be created in two different modes:
a Datasheet view
b Design view
Select the create table design view from the database window menu. As a result, the
following screen will appear.
Specify the field names and data types. The data type of a field indicates the nature of
the field. Below can also be seen the list of data types offered by MS Access.
After saving the table, to enter data in the table, the user right clicks the mouse and
the following screen appears.
In the design view, select the lookup wizard option from the data type field.
When the user selects the above option the below screen will appear. The first option
lets you lookup field to get values from another table or query.
4
5
By clicking on the next button the wizard will let the user enter different values as
seen below in the screenshot.
After selecting the table, the user can select the field from which the values can be
picked.
The user can finalize by clicking the finish button to create the lookup.
2. For inserting the OLE data, right-click in the text box in the datasheet view and the
user can see the option of Insert Object.
3. The below screenshot shows the Cust_ID field sorted from the largest value to the
smallest value.
1. By clicking on the extreme right on the column title, the filter menu will open. Here
we can see that the filter has been applied to select only those customer who belong to
the state of Banglore.
2. Select the Excel option in the External Data tab on the main menu.
3. The following window will open with three options. With the first option we can
import the data into a new table in the current database. If a table already exists in the
database with the same name it will be overwritten. After browsing the Excel file
press the OK button
4. On clicking the OK button the following screen will appear. If the spread sheet
contains first row as column headers then select the checkbox.
5. After clicking the NEXT button the following screen will appear. The user can specify
information about each field by selecting the fields in the area below.
6. In the final step specify the table name that the user wants to keep.
7. After the FINISH button has been clicked the data is imported in Excel as can be seen
from the below screenshot.
Creating Relationships
Relationship helps to join two or more tables and enables to make automatic changes in the
joined tables. The user need not make changes in the tables separately. Under referencing,
first create tables having one common unique field. In addition, assign a primary key to the
common unique field in both the tables. After assigning the primary key to the unique fields
in both the tables, when the user makes any changes in the entries of the primary field in the
first table, the second table gets automatically updated.
After creating the tables, select relationship option from the database tools in the main menu.
Select the show table command to display the stored tables in the particular database.
Add the tables on which the user wants and build relationships. Finally the relation
will be as seen in snapshot.
Queries
After creating the database, next important application of MS Access is the queries. The user
can ask specific questions in order to retrieve specific information according to the
requirements.
Simple Queries
Following are the steps for creating a new query with just a single table.
1. Click on the create option of the main menu and select query design.
2. The user then selects the particular table on which he wants to apply he query. To
create a query, select the relevant fields in the lower section of the application.
3. For example, the user wants to see the order places after a particular date. The user
can specify the same in the Criteria field
When the user runs the query, the result will be as follows.
Advanced Queries
User can also design advanced queries which can have more than one table. Following are the
steps for creating a new query with multiple tables.
1. Select the tables from which the data needs to be fetched. . To create a query, select
the relevant fields in the lower section of the application.
2. When the user runs the query, the result will be as follows.
Forms
Forms show the desired information stored in the data. They can also be used to directly enter
data and the entered data is saved in the selected tables. The user can create a form using the
Form Wizard option and Form Design option.
In the create tab of main menu, click on Form Wizard and then select the table/query for
which form has been created. After table, select the required fields as well.
Next, select the particular layout in which you want to view the final format of the form. In
the below example tabular layout has been selected.
In the next step, provide the name of the form. The form will be saved in this name.
Once the finish button is clicked, the final form will appear.
2. Select the Add Existing Fields option from the design menu. All the names of the
saved tables/queries will appear on the right side of the window; select the required
table and drag the fields to the form screen.
3. Save the form in the name of your choice. The final form will on the screen
Reports
A manager has to report various activities on different parameters. MS access provides the
facility of creating reports. The reports can be generated in the two ways i.e. directly from the
form and secondly from the Report Wizard.
3. Give a title to this report. The report will be saved in this title. After
clicking the finish button, the final report will be generated. The manager
can take the printout of this report and submit it to the parties he wants.