Reservation of railway tickets, account details of customers of a bank, schedule of trains are some of the common applications that use computerized databases. A database management system is required to store, access, manipulate and manage data in the database. MS-Access is commonly used relational database management system. The purpose of this chapter is to introduce you to MS-Access.
A database is a collection of logically-related and similar data. Database stores similar kind of data, for a specific purpose that is organized in such a manner that any information can be derived from it, when needed. The database is accessed for the retrieval, insertion, deletion, or updating of data. Database Management System (DBMS) is a software system for creating, organizing, and managing the database. DBMS provides an environment to the user to perform operations on the database for creation, insertion, deletion, updating, and retrieval of data.
Some of the common used DBMSs are—Oracle, IBM’s DB2, Microsoft’s SQL Server, and Informix. Some of the desktop based DBMSs are—Microsoft Access, Microsoft FoxPro, and Borland dBase. MySQL is a popular open source DBMS.
Microsoft Access is an application which allows the creation of databases for the Microsoft Windows family of operating systems. Microsoft Access is a Relational Database Management System (RDBMS). It can also be used as a database server for a web-based application. It is supported by the ODBC and the .NET Framework.
Access is a tool for managing the databases. Database can store any kind of data—numbers, pages of text, and pictures. Databases can also handle wide range of data size—from a few hundreds to many millions. Access allows you to design and create complete databases with quick and easy data entry, maintain them, and search for information.
Within Access there are four major areas—Tables, Queries, Forms, and Reports.
Some of the important features of MS-Access are as follows:
This chapter discusses the using of MS-Access software in detail. There are many versions of the MS-Access software. Here, we will discuss MS-Access 2007 version.
In this chapter, the following terminology is used while working with the mouse:
The command enclosed in braces <Command> represents the command to be clicked.
The database terminology required for the use of MS-Access is described as follows:
Figure 19.1 MS-Access icon
MS-Access software for the Windows operating system is installed on the computer. MS-Access is a fully menu-driven software, and the commands are available as icons in various Tabs and Groups. Using a mouse makes working on MS-Access simpler, although one can work to some extent through the keyboard also.
To start using the MS-Access software, any one of the following steps need to be performed:
Figure 19.2 Start MS-Access
The user interface of MS-Access makes it easy for you to work in Access 2007. In contrast to the previous versions of MS-Access, the new user interface has an improved navigation system consisting of tabs which further consist of group of commands.
When Microsoft Access 2007 is started, the screen Getting Started with Microsoft Office Access screen (Figure 19.3) comes up.
Click <Blank database> <Create>
Enter the name of the database, and browse to the location where the database is to be stored on the disk.
Figure 19.3 Getting started with Microsoft Office Access screen
Now, the MS-Access 2007 screen (Figure 19.4) comes up. This window consists of a number of components to make working in Access easier and more efficient. Some of the components are—Navigation Pane, Access work area, View Buttons, and Ribbon. On the MS-Access screen, some of the features like the Office Logo button, Quick Access Toolbar and Ribbon are common to all Microsoft Office programs like MS-Word, MS-Excel, and MS-PowerPoint. The orientation of the Access 2007 layout and its general features are described as follow:
Figure 19.4 MS-Access 2007 screen
Figure 19.5 The ribbon
The functionality of Office button in MS-Access is almost similar to the functionality provided in MS-Word, MS-Excel, and MS-PowerPoint software. For example, New will open a blank document in MS-Word, a blank workbook in MS-Excel, a blank presentation in MS-PowerPoint, and a blank database in MS-Access.
The Office Button is used to perform file management operations on the file (i.e. the database). It contains commands that allow the user to create a new database, open an existing database, save a database, print a database etc. The Office button contains nine commands (Figure 19.6), namely, New, Open, Save, Save As, Print, Manage, E-mail, Publish, and Close Database. The working of these commands is almost similar to their working in MS-Word. Here, we will discuss them briefly.
Figure 19.6 The Office button commands
Table 19.1 briefly describes the different commands available in the Office Button.
Office Button Commands | Description |
New | Create a new blank database that does not contain any objects. You can also select from different templates like Assets, Faculty, Issues, and Tasks. |
Open | Open an already existing database |
Save | Save a database for which a file name and location has already been specified. |
Save As | Use when you save the database at a different location or by a different name or with a different save type. Specify the filename for the database, the location where the database is to be stored, and the save type of the database (table, query, form or report). The database can also be saved as Access 2007 database, Access 2002-2003 database etc. |
Print, Quick Print, Print Preview the database. Properties like print quality, paper type etc. and print the selected records or the entire database, can also be set. Preview to see how the database will look after printing. | |
Manage | View database properties, compact and repair the database and take back-up of the database (Figure 19.7) |
Send a copy of the database to e-mail | |
Publish | Share the database by saving it to a document management server, package the database, and apply a digital signature. |
Close Database | Close an open database. |
Table 19.1 Office button commands description
Figure 19.7 Publish option
The following describes briefly some of the common operations that are performed using the commands of the Office Button.
Figure 19.8 Print dialog box
When working with MS-Access, all you need to know is the following:
Here I describe how you can go about learning MS-Access.
What a command does—When you keep your mouse pointer over a command or icon, the function of the command or icon is displayed in a text box. So you can know what a command does by moving the mouse over the command.
Which command to use—
Once you are able to find the command, then you should know how to use the command.
Like the other programs in the Office 2007 suite, MS-Access 2007 has a ribbon. The Ribbon of MS-Access has the Office button and five Tabs, namely, Home, Create, External Data, Database Tools and Add-Ins. Each tab further consists of the groups, and the groups contain icons. Icons are a pictorial representation for a command. The tabs in the Ribbon are self-explanatory; for example, if you want to create a form, click on the Create tab. The groups and icons related to Create are displayed on the screen. Select the appropriate command. The different tabs in MS-Access and the groups within them are as follows:
The Add-Ins tab contains supplemental functionality that adds custom commands and specialized features to MS-Access.
The commands in the Ribbon have various symbols associated with them, as shown in Figure 19.9. These symbols are interpreted as follows—
Selecting a command | |
Ways to select a command | Using a command |
Click on a Tab + Click on a Icon | Click on any of the Tabs like Home, Create etc. From the displayed icons, click on the icon you want to use. |
Shortcut key Ctrl + letter | Some commands have shortcuts where you can press the Ctrl key and a certain letter. Some commonly used shortcuts are- |
• Paste: CTRL + V • Copy: CTRL + C • Undo: CTRL + Z • New document: CTRL + N • Open document: CTRL + O • Print document: CTRL + P |
Figure 19.9 Command symbols
The following sub-sections describe the different tabs in detail.
The Home Tab contains commands that are frequently used in an Access database. It contains commands for the formatting of text, text alignment, and performing operations on the records. The Home Tab is also used to change the views while working with tables. It is also possible to edit contents of the database like, sort and filter, find and select, and, to perform clipboard operations such as cut, copy, and paste, using the commands available in the Home tab. Figure 19.10 shows the Home Tab.
Figure 19.10 The home Tab
There are seven groups within this tab, namely, Views, Clipboard, Font, Rich Text, Records, Sort & Filter, and Find.
Table 19.2 gives the commands in the different groups (in left to right order) of the Home Tab along with a brief explanation.
Home Tab Groups | Description |
---|---|
Views | • View as Datasheet view, Pivot Table view, Pivot Chart view and Design view. Datasheet view is the default view. It allows you to enter data into a table and lets you build the table as you insert new information. Design view lets you define all aspects of a table before you start using it. |
Clipboard | • Paste the cut or copied items in Clipboard at the location where cursor is pointing right now (Paste Special — to paste in a particular format. Paste Append — to paste the copied items at the last of existing list). • Cut removes the selected item and puts into Clipboard for later retrieval. • Copy copies the selected item and puts it on the Clipboard. • Format painter copies formatting from one place and apply it to another (To apply same formatting to many places, double-click the format painter button). |
Font | • Change Font face, change font size. • Align text left, centre or right. • Bold, Italics, Underline. • Change the Font color. • Color the background of the selected cells. • Show gridlines- horizontal, vertical, both or none. • Alternate fill the back color. In this, alternately the background is colored. |
Rich Text | • Increase or decrease the indentation level. • Set the direction of text to be displayed from left to right. • Start a numbered list or a bulleted list. • Make the text look like it is marked with highlighter pen. |
Records | • Refresh all records when in datasheet view or in a form. • Create a new record in data sheet view or form. • Add the field Total Rows in the table to find the total number of records when in datasheet view. • Save the records when in datasheet view or in a form. • Perform spell check on the entries in a table. The Spelling dialog box will display when an error is located.. • Delete records from a table. • Adjust row height, column width, hide or unhide columns, freeze or unfreeze column. This button is only available in datasheet view. |
Sort & Filter | • Sort in ascending or descending order. • Clear the sort order that was applied to a table with the ascending and descending buttons. • Apply filter. A filter menu opens. Specify the criteria for displaying records in a table. • Selection — selects records that meet specified criteria in a table field. A list of entries in the field will display. Click the item in the list to display the records that match that criterion. • Advanced — opens the Advanced Filter menu; used to specify more advanced filtering options. • Toggle filter to display the filtered records and all the records in a table. |
Find | • Find a record meeting specified criterion. The Find and Replace dialog box will display where the criterion can be specified. • Replace — To locate data in a table and replace it with new data. The Find and Replace dialog box will display where the criterion can be specified. • Go to the First, Previous, Next, Last, or New record in a table. • Select the record where the insertion point is located or all records in a table. |
Table 19.2 Home tab commands description
Here, some of the operations that are performed using the commands of the Home Tab are described briefly:
Figure 19.11 Design view
Figure 19.12 Datasheet view
Figure 19.13 Apply filter
The Create Tab contains commands for inserting different kinds of database objects. The commands in this tab are used to add tables that store data, queries that search it, forms that help edit it, and reports that help print it. Figure 19.14 shows the Create Tab.
Figure 19.14 The create tab
There are four groups within this tab, namely, Tables, Forms, Report, and Other.
Some of the Tabs appear only when you use them; like Table Tools tab, Report Layout Tools Tab, and Form layout Tools Tab
Table 19.3 gives commands in the different groups of Create Tab along with a brief explanation. Some of the tool tabs that appear when a tool is used are shown from Figure 19.15 to Figure 19.18.
Create Tab Groups | Description |
---|---|
Tables | • Table—create a new blank table. Specify the fields directly in the new table or open the table in Design view. • Table Templates—create a new table using a table template like contacts, issues, tasks etc. • SharePoint Lists—create a list on the SharePoint site and a table in the current database that links to the newly created list • Table Design—create a new blank table in Design view. Add fields, set indexing options and perform other advanced table-defined tasks |
Forms | • Form—Create a form that lets you enter information one record at a time. • Split form—Create a split form upper section and a form in the lower section for entering information about the record selected in the datasheet. • Multiple items—Create a form that shows multiple records in a datasheet with one record per row. • Pivot Chart—to display data from a table in different types of relationships. • Blank form—to create a form that does not contain any fields or data. Move the fields into the form from the list of fields that appear on the right side of form. • More forms—to display a list of additional form creation options like Form Wizard, Datasheet, and Pivot Table. • Form design—to create a form in Design View. |
Reports | • Report—to create an instant report. • Labels—to launch the Label Wizard where standard or customized labels may be created. • Blank Report—to create a report without any fields specified. After the report has been created, fields can be inserted. • Report Wizard—to launch the Report Wizard to create customized reports. • Report Design—to create a report in Design View. Advanced design changes can be made to the report. |
Other | • Query Wizard—to create a simple query, crosstabs query, find duplicates query, or find unmatched query. • Query Design—to create a new blank query. The Show Table dialog box appears. Select a table for creating query. • Macro—to insert macros into the database. |
Table 19.3 Create tab commands description
Figure 19.15 Table tools datasheet tab
Figure 19.16 Form layout tools format tab
Figure 19.17 Report layout tools format tab
Figure 19.18 Query tools design tab
Some of the operations using the Create Tab commands are described below:
The External Data Tab contains commands for importing data into Access and exporting it to other programs. The External Data Tab is shown in Figure 19.19.
Figure 19.19 The external data tab
There are four groups within this tab, namely, Import, Export, Collect Data, and SharePoint Lists.
Table 19.4 gives the commands in the different groups of the External Data Tab along with a brief explanation.
External Data Tab Group | Description |
---|---|
Import | • Saved imports—to view and run an import operation that was saved previously. • Access—to import data from or link to another Access database. • Excel—To import data from or link to an Excel file. • SharePoint list—to import data from or link to a SharePoint List. • Text file—to import a text file. • XML file—to import an XML file. • More—to display a list of additional formats from which data may be imported from. |
Export | • Saved Exports—to view and run an export operation that was saved previously. • Excel—to export the selected object in Access to an Excel worksheet. • SharePoint List—to export the selected object to a SharePoint list. • Word—to export the selected object to a Rich Text Format document. • Text File—to export a selected object to a text file. • More—to display a list of additional formats into which a selected object may be exported. |
Collect Data | • Create e-mail—to create an e-mail message that includes a form for collecting information from users. • Manage Replies—to view replies to data collected in email messages and use them to update databases. |
SharePoint Lists | • Work Online—to take all data offline. The data is synchronized when the computer is reconnected to the network. • Synchronize the data between the database and the SharePoint server. • Discard changes made to the database on the SharePoint Server. • Cache List Data—to cache list data on the database server. • Relink Lists—to re-link the broken link between the database server and the SharePoint server. • Move to Share Point some or all parts of a database. |
Table 19.4 External Data commands description
Some of the operations that are performed using the commands of the External Data tab are briefly described below:
The Database Tools Tab has tools that help experts perform data analysis and add Visual Basic code (a scripting language). This tab is used for the linking of tables. The Database Tools Tab is shown in Figure 19.20.
Figure 19.20 The database tools tab
There are five groups within this tab, namely, Macro, Show/Hide, Analyze, Move Data, and Database Tools.
Table 19.5 gives the commands in the different groups of the Database Tools Tab along with a brief explanation.
Database Tools Tab Group | Description |
---|---|
Macro | • Visual Basic — Launch the visual basic editor. • Run a macro, create shortcut menu from macro and convert macros to visual basic. |
Show/Hide | • Define how the data in the tables are related. • Open the object’s property sheet to set its properties. • Show the database object like query and tables that rely on other objects. • Show or hide the message bar. |
Analyze | • Analyze the database documenter, analyze the performance of the table, form, query etc. |
Move Data | • Migrate some parts of the database to a new or an existing SQL server database. • Split the database into two files - one containing the table and the other containing the forms and queries. |
Database Tools | • Database tools for encrypting the database with password, switch-board manager etc. |
Table 19.5 Database tools tab commands description
The Help button is located on the right most side of the Tabs in the Ribbon. Click on this button to get help for using any command of the Access. On clicking on the help button, a screen as shown in Figure 19.21 appears. Browse the Help for the specific command. It also allows for operations such as search for a command and view Table of Contents.
Many of the concepts that used while working with MS-Office suite are common for MS-Word, MS-PowerPoint, MS-Access, and MS-Excel. For example, open, close, save, cutting, and pasting are performed the same way in MS-Access as they are in MS-Word, and MS-PowerPoint. The menus are also arranged in a similar layout. If you are not sure how to do something in Access, then try it as one would do in MS-Word or MS-PowerPoint, and it may work.
Figure 19.21 Access help
This is an example to create a database and query it.
Example 1: Create COMPANY relational database schema, as follows:
COMPANY RELATIONAL DATABASE SCHEMA
RELATION NAME | ATTRIBUTES |
EMPLOYEE | Fname, Minit, Lname, SSN, Bdate, Address, Sex, Salary, Superssn, Dno |
DEPARTMENT | Dname, Dnumber, Mgrssn, Mgrstartdate |
DEPT_DLOCATION | Dnumber, Dlocation |
PROJECT | Pname, Pnumber, Plocation, Dnum |
WORKS_ON | ESSN, Pno, Hours |
DEPENDENT | ESSN, Dependent name, Sex, Bdate, Relationship |
The underlined fields are the primary key. Fill data into the table and perform the following Queries:
Solution 1.
EMPLOYEE TABLE
DEPARTMENT TABLE
DEPT DLOCATION TABLE
PROJECT TABLE
DEPENDENT TABLE
WORKS_ON TABLE
Sql view
SELECT fname, lname, mgrstartdate
FROM department, employee
WHERE mgrssn=ssn;
Sql view
SELECT DISTINCT fname, lname
FROM employee, works_on
WHERE pno in (select pno
from works_on,employee
where fname=‘john’ and lname=‘smith’ and essn=ssn;)
and essn=ssn;
Sql view
SELECT fname, lname,employee.sex,ssn, dependent_name
FROM employee, dependent
WHERE employee.sex=‘m’ and essn=ssn
UNION SELECT fname, lname,employee.sex,ssn, dependent_name
FROM employee, dependent
WHERE employee.sex=‘f’ and essn=ssn;
Sql view
SELECT dno, count(dno) AS no_of_employees, avg(salary) AS avg_salary
FROM employee
WHERE dno in(select dno
from department
where mgrssn=ssn and fname=‘john’ and lname=‘smith’;)
GROUP BY dno;
Sql view
SELECT ssn, dname
FROM employee, department
WHERE dno=dnumber;
Sql view
SELECT ssn, fname, lname, dno
FROM employee AS e1
WHERE e1.salary >
(
select max(salary)
from employee as e2 where e1.superssn=e2.ssn;
);
RELATION NAME | ATTRIBUTES |
---|---|
SUPPLIER | SNo, Sname, Status, City |
PARTS | PNo, Pname, Color, Weight, city |
PROJECT | Ino, Jname, City |
SHIPMENT | Sno, Pno, Ino, Quantity |
The underlined fields are the primary key. Fill in the appropriate data in the tables. Perform the following queries:-
PURCHASE ORDER RELATIONAL DATABASE SCHEMA
RELATION NAME | ATTRIBUTES |
---|---|
VENDOR | Vendorno, vname, street, city, region, zip, contact |
PRICEINFO | Partno, vendorno, catno, price |
POHEADER | Orderno, orddate, vendorno, invoiceno, status |
PODETAIL | Orderno, partno, qty, unit-pr |
PART | Partno, description |
POHISTORY | Orderno, orddate, vendorno, invoiceno, pototal |
The underlined fields are the primary key. Fill data into the table and perform the following Queries:
RELATION NAME | ATTRIBUTES |
---|---|
BOOKS | Book id, Book name, Author name, Publishers, Price, Type, Quantity |
ISSUED | Book id, qty issued |
The underlined fields are the primary key. Fill data into the table and perform the following Queries:
LIBRARY MANAGEMENT RELATIONAL DATABASE SCHEMA
RELATION NAME | ATTRIBUTES |
---|---|
BOOK | Book id, title, pub_id |
BOOK_AUTHORS | Book id, author name |
BOOK_COPIES | Book id, branch id, noof_copies |
BOOK_LOANS | Book id, branch id, card no, dateout, duedate |
LIBRARY_BRANCH | Branch id, branch_name, address |
BORROWER | Card no, name, address, phone |
PUBLISHER | Pub id, Pub_name, address, phone_no |
The underlined fields are the primary key. Fill data into the table and perform the following Queries:
3.143.235.219