Dbms Aditya File
Dbms Aditya File
Microsoft Access is just one part of Microsoft’s overall data management product strategy.
It stores data in its own format based on the Access Jet Database Engine.
Like relational databases, Microsoft Access also allows you to link related information
easily. For example, customer and order data. However, Access 2013 also complements
other database products because it has several powerful connectivity features.
It can also import or link directly to data stored in other applications and databases.
As its name implies, Access can work directly with data from other sources, including
many popular PC database programs, with many SQL (Structured Query Language)
databases on the desktop, on servers, on minicomputers, or on mainframes, and with data
stored on Internet or intranet web servers.
Access can also understand and use a wide variety of other data formats, including many
other database file structures.
You can export data to and import data from word processing files, spreadsheets, or
database files directly.
Access can work with most popular databases that support the Open Database
Connectivity (ODBC) standard, including SQL Server, Oracle, and DB2.
Microsoft Access stores information which is called a database. To use MS Access, you will need
to follow these four steps −
Database Creation − Create your Microsoft Access database and specify what kind of
data you will be storing.
Data Input − After your database is created, the data of every business day can be entered
into the Access database.
Query − This is a fancy term to basically describe the process of retrieving information
from the database.
Report (optional) − Information from the database is organized in a nice presentation that
can be printed in an Access Report.
Architecture
Access calls anything that can have a name an object. Within an Access desktop database,
the main objects are tables, queries, forms, reports, macros, data macros, and modules.
If you have worked with other database systems on desktop computers, you might have
seen the term database used to refer to only those files in which you store data.
But, in Access, a desktop database (.accdb) also includes all the major objects related to
the stored data, including objects you define to automate the use of your data.
PRACTICAL-2
The data type determines the kind of the values that users can store in any given field.
Each field can store data consisting of only a single data type.
Here are some of the most common data types you will find used in a typical Microsoft Access database.
If you use previous versions of Access, you will notice a difference for two of those data types.
In Access 2013, we now have two data types — short text and long text. In previous versions of
Access these data types were called text and memo.
The text field is referred to as short text and your memo field is now called long text.
PRACTICAL-3
To create a database from a template, we first need to open MS Access and you will see the
following screen in which different Access database templates are displayed.
To view the all the possible databases, you can scroll down or you can also use the search box.
Let us enter project in the search box and press Enter. You will see the database templates related
to project management.
Select the first template. You will see more information related to this template.
After selecting a template related to your requirements, enter a name in the File name field and
you can also specify another location for your file if you want.
Now, press the Create option. Access will download that database template and open a new blank
database as shown in the following screenshot.
Now, click the Navigation pane on the left side and you will see all the other objects that come
with this database.
Click the Projects Navigation and select the Object Type in the menu.
You will now see all the objects types — tables, queries, etc.
Create Blank Database
Sometimes database requirements can be so specific that using and modifying the existing
templates requires more work than just creating a database from scratch. In such case, we make
use of blank database.
Step 3 − Access will create a new blank database and will open up the table which is also
completely blank.
PRACTICAL-4
Let us try and create the first table that will store the basic contact information concerning the
employees as shown in the following table −
EmployeelD AutoNumber
Let us now have short text as the data type for all these fields and open a blank database in Access.
This is where we left things off. We created the database and then Access automatically opened
up this table-one-datasheet view for a table.
Let us now go to the Field tab and you will see that it is also automatically created. The ID which
is an AutoNumber field acts as our unique identifier and is the primary key for this table.
The ID field has already been created and we now want to rename it to suit our conditions. This
is an Employee table and this will be the unique identifier for our employees.
Click on the Name & Caption option in the Ribbon and you will see the following dialog box.
Change the name of this field to EmployeeID to make it more specific to this table. Enter the
other optional information if you want and click Ok.
We now have our employee ID field with the caption Employee ID. This is automatically set to
auto number so we don't really need to change the data type.
Type FirstName as the field name. Similarly, add all the required fields as shown in the following
screenshot.
Once all the fields are added, click the Save icon.
You will now see the Save As dialog box, where you can enter a table name for the table.
Enter the name of your table in the Table Name field. Here the tbl prefix stands for table. Let us
click Ok and you will see your table in the navigation pane.
Project ID AutoNumber
ProjectName Short Text
Contracts Attachment
ProjectStart Date/Time
ProjectEnd Date/Time
Budget Currency
Click Ok and you can now see what this table looks like in the Datasheet View.
Let us click the datasheet view button on the top left corner of the ribbon.
If you ever want to make changes to this table or any specific field, you don't always have to go
back to the Design View to change it. You can also change it from the Datasheet View. Let us
update the PStatus field as shown in the following screenshot.
A datasheet is a simple way to look at your data in rows and columns without any special
formatting.
Whenever you create a new web table, Access automatically creates two views that you
can start using immediately for data entry.
A table open in Datasheet View resembles an Excel worksheet, and you can type or paste
data into one or more fields.
You do not need to explicitly save your data. Access commits your changes to the table
when you move the cursor to a new field in the same row, or when you move the cursor
to another row.
By default, the fields in an Access database are set to accept a specific type of data, such
as text or numbers. You must enter the type of data that the field is set to accept. If you
don't, Access displays an error message −
Let us add some data into your tables by opening the Access database we have created.
Select the Views → Datasheet View option in the ribbon and add some data as shown in the
following screenshot.
Similarly, add some data in the second table as well as shown in the following screenshot.
You can now see that inserting a new data and updating the existing data is very simple in
Datasheet View as working in spreadsheet. But if you want to delete any data you need to select
the entire row first as shown in the following screenshot.
Now press the delete button. This will display the confirmation message.
Click Yes and you will see that the selected record is deleted now.
PRACTICAL-5
As tables grow in size they can have hundreds of thousands of records, which makes it
impossible for the user to pick out specific records from that table.
With a query you can apply a filter to the table's data, so that you only get the information
that you want.
Queries that you use to retrieve data from a table or to make calculations are called select
queries.
Queries that add, change, or delete data are called action queries.
You can also use a query to supply data for a form or report.
In a well-designed database, the data that you want to present by using a form or report is
often located in several different tables.
The tricky part of queries is that you must understand how to construct one before you can
actually use them.
In the tblEmployees table, double-click all those fields which you want to see as result of the
query. Add these fields to the query design grid as shown in the following screenshot.
A query criterion is an expression that Access compares to query field values to determine
whether to include the record that contains each value.
Some criteria are simple, and use basic operators and constants. Others are complex, and
use functions, special operators, and include field references.
To add some criteria to a query, you must open the query in the Design View.
You then identify the fields for which you want to specify criteria.
Example
Let’s look at a simple example in which we will use criteria in a query. First open your Access
database and then go to the Create tab and click on Query Design.
In the Tables tab on Show Table dialog, double-click on the tblEmployees table and then close
the dialog box.
Let us now add some field to the query grid such as EmployeeID, FirstName, LastName, JobTitle
and Email as shown in the following screenshot.
Let us now run your query and you will see only these fields as query result.
If you want to see only those whose JobTitle are Marketing Coordinator then you will need to
add the criteria for that. Let’s go to the Query Design again and in Criteria row of JobTitle enter
Marketing Coordinator.
Let us now run your query again and you will see that only Job title of Marketing Coordinators
are retrieved.
If you want to add criteria for multiple fields, just add the criteria in multiple fields. Let us say
we want to retrieve data only for “Marketing Coordinator” and “Accounting Assistant”; we can
specify the OR row operator as shown in the following screenshot −
Let us now run your query again and you will see the following results.
If you need to use the functionality of the AND operator, then you have to specify the other
condition in the Criteria row. Let us say we want to retrieve all Accounting Assistants but only
those Marketing Coordinator titles with “Pollard” as last name.
Let us now run your query again and you will see the following results.
PRACTICAL-7
Forms in Access are like display cases in stores that make it easier to view or get the items that
you want. Since forms are objects through which you or other users can add, edit, or display the
data stored in your Access desktop database, the design of your form is an important aspect.
There's a lot you can do design-wise with forms in Microsoft Access. You can create two basic
types of forms −
Bound forms
Unbound forms
Bound Forms
Let us now understand what Bound Forms are −
Bound forms are connected to some underlying data source such as a table, query, or
SQL statement.
Bound forms are what people typically think of when they think of the purpose of a form.
Forms are to be filled out or used to enter or edit data in a database.
Examples of bound forms will typically be what users use to enter, view or edit data in a
database.
Unbound Forms
Let us look into Unbound Forms −
Split Form
The form is divided into halves, either vertically or horizontally. One half displays a single item
or record, and the other half displays a list or provides a datasheet view of multiple records from
the underlying data source.
Creating Forms
There are a few methods you can use to create forms in Access. For this, open your Database and
go to the Create tab. In the Forms group, in the upper right-hand corner you will see the Form
Wizard button.
Let us assume we want to simply have a quick form that we are going to use for data entry for
our employee information.
From Tables/Queries drop-down list, select tblEmployeestable. Click on the double arrow to
move all the fields at once.
Let us just leave it with that one table, and click Next.
The following screen in the Form Wizard will ask for the layout that we would like for our form.
We have columnar, tabular, datasheet and justified layouts. We will choose the columnar
layout here and then click Next.
In the following screen, we need to give a title for our form. Let us call it form Employees.
Once you have given your form a title, you can open the form to see what that form looks like, or
you can begin entering information into your table. Or you can choose the option to modify the
form's design. Let us choose the first option to open the form to view or enter information and
click Finish.
Now, take a look at the following screenshot. This is what your form looks like. This is a single
item form, meaning one record is displayed at a time and further down you can see the navigation
buttons, which is telling us that this is displaying the record 1 of 9. If you click on that button
then, it will move to the next record.
If you want to jump to the very last record in that form or that table, you can use the button right
beside that right arrow, the arrow with a line after it, that's the last record button. If you want to
add new employee information, go to the end of this records and then after 9 records you will see
a blank form where you can begin entering out the new employee's information.
This is one example of how you can create a form using the Form Wizard. Let us now close this
form and go to the Create tab. Now we will create a slightly more complicated form using Wizard.
Click the Form Wizard and this time, we will choose fields from a couple of different tables.
In this Form Wizard, let us choose tblProjects for Tables/Queries, and select a few Available
Fields such as ProjectID, ProjectName, ProjectStart, and ProjectEnd. These fields will now move
to Selected Fields.
Now select tblTasks for Tables/Queries and send over the TaskID, ProjectID, TaskTitle,
StartDate, DueDate and PercentComplete. Click Next.
Here, we want to retrieve data from a couple of different objects. We can also choose from options
on how we want to arrange our form. If we want to create a flat form, we can choose to arrange
by tblTasks, which will create that single form, with all the fields laid out in flat view as shown
above.
However, if we want to create a hierarchical form based on that one-to-many relationship, we can
choose to arrange our data by tblProjects.
In the above window, we have the option to include a subformfor tblTasks, or we can make that
a linked form. This linked form is where tblProjects will have a button that will launch that second
form filtered to the project that we have selected in that underlying projects form. Let us now
select the Form with subform(s), and then click Next.
In the following screen, you can choose a layout for your subform. The Datasheet View gets
selected by default. The Datasheet View is similar to Table View. Now, click Next.
In the following screen, you need to provide a name for your forms. Enter the name you want and
click Finish.
Access will give you a preview of what your form looks like. On top, you have the controls on
your main form, which is from our Projects table. As you go down, you will see a subform. It's
like a form within a form.
To create this type of form, you will need to select the object in navigation pane first. Let us
select tblEmployees here.
Proceed by clicking on More Forms and Multiple Items.
The above step will further create a Multiple Items form, listing out all the employees.
Split Form
This type of form is divided in equal halves, either vertically or horizontally. One half displays a
single item or record, and the other half displays a list or a datasheet view of multiple records
from the underlying data source.
Let us now select tblEmployees in the navigation pane and then on Create tab. Select Split
Form option from More Forms menu and you will see the following form in which the form is
divided vertically.
PRACTICAL-8
The Save As command is generally used to save a document in another format, so that you
can open it in another program.
In Access you can’t use the Save As command in the same way, you can save Access
objects as other Access objects, but you cannot save an Access database as a spreadsheet
file.
To save Access as a spreadsheet file, you will need to use the import feature on the External
Data tab.
In Import & Link group, you will see an option Excel. Let us click on that option.
Browse the Excel file from which you want to import data and the then we have different options
to store data. Let us select the first option and click Ok.
Here you will see the preview of your data. Now, click Next.
In the Preview, you can now see that the first row contains the column headings. Let us now check
the check box and click Next.
You will now see a dialog box where you can set the data type for each column/field. If you don’t
want to import any field, just check the check box which says do not import field. Once you are
done with the FirstName field, just click on the MiddleInitial field.
Let us now go through all the fields and then, click Next.
Here are the different options for primary key. Let us select the first option and click Next.
In the last dialog box, you can enter the table name of your choice and click Finish.
If you want to save all these steps, then check the checkbox and close the dialog box.
Let us now go to the Navigation pane. You will see a new table is added here and when you open
the newly added table you will see all of your data in Access.
Example
Let us now look at another example of importing data from the Access database. Let us go to the
External Tab again.
We will understand how to export data from Access. Data export is actually the opposite of
importing data. In importing data, we bring data from other formats in Access, while in exporting
we save the data in other formats.
To understand what kind of data you can export from Access data, let us open your database and
go to the External Data tab.
In the Export group, you can see the different kind of options available for data export from
Access. Following are the most commonly used data export formats −
XML Files
Example
Let us look at a simple example of data export from Access. Open your database where you want
to export the data from. In the Navigation Pane, select the object that you want to export the data
from.
You can export the data from table, query, form, and report objects etc. Let us select the
qryAllProjects and then, go to the External Data tab.
On the External Data tab, click on the type of data that you want to export to. For example, to
export data in a format that can be opened by Microsoft Excel, click Excel.
Access starts the Export wizard. In the wizard, you can set the information such as the destination
file name and format, whether to include formatting and the layout, which records to export. Once
you are done with the required information, click Ok.
On this screen of the Wizard, Access usually asks you if you want to save the details of the export
operation. If you think you will need to perform the same operation on a recurring basis, select
the Save export steps check box and close the dialog box.
Let us now understand One-to-One Relationship in MS Access. This relationship is used to relate
one record from one table to one and only one record in another table.
Click on the Save icon and open tblHRData and you will see that the data we have entered is
already here.