0% found this document useful (0 votes)
41 views

Dbms Aditya File

The document discusses creating and managing databases in Microsoft Access. It covers creating a database from templates or from scratch, creating tables and fields, and adding data to tables.

Uploaded by

Aditya Aryaveer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views

Dbms Aditya File

The document discusses creating and managing databases in Microsoft Access. It covers creating a database from templates or from scratch, creating tables and fields, and adding data to tables.

Uploaded by

Aditya Aryaveer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 86

PRACTICAL-1

AIM: To study MS-ACCESS.


Microsoft Access is a Database Management System (DBMS) from Microsoft that combines the
relational Microsoft Jet Database Engine with a graphical user interface and software
development tools. It is a member of the Microsoft Office suite of applications, included in the
professional and higher editions.

 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.

 Software developers can use Microsoft Access to develop application software.

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

AIM: To study various data types.


Every field in a table has properties and these properties define the field's characteristics and
behavior. The most important property for a field is its data type. A field's data type determines what
kind of data it can store. MS Access supports different types of data, each with a specific purpose.

 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.

Type of Data Description Size

Text or combinations of text and Up to 255 characters.


numbers, including numbers that do
Short Text
not require calculating (e.g. phone
numbers).

Lengthy text or combinations of text Up to 63, 999 characters.


Long Text
and numbers.

Numeric data used in mathematical 1, 2, 4, or 8 bytes (16 bytes if set to


Number
calculations. Replication ID).

Date and time values for the years 100 8 bytes


Date/Time
through 9999.

Currency values and numeric data used 8 bytes


Currency in mathematical calculations involving
data with one to four decimal places.

A unique sequential (incremented by 4 bytes (16 bytes if set to Replication


AutoNumber
1) number or random number assigned ID).
by Microsoft Access whenever a new
record is added to a table.

Yes and No values and fields that 1 bit.


Yes/No contain only one of two values
(Yes/No, True/False, or On/Off).

 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

AIM: To create database in MS-ACCESS.


We will be covering the basic process of starting Access and creating a database. This chapter
will also explain how to create a desktop database by using a template and how to build a database
from scratch.

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 1 − Let us now start by opening MS Access.


Step 2 − Select Blank desktop database. Enter the name and click the Create button.

Step 3 − Access will create a new blank database and will open up the table which is also
completely blank.
PRACTICAL-4

AIM: To create table and add data in table.


When you create a database, you store your data in tables. Because other database objects depend
so heavily on tables, you should always start your design of a database by creating all of its tables
and then creating any other object. Before you create tables, carefully consider your requirements
and determine all the tables that you need.

Let us try and create the first table that will store the basic contact information concerning the
employees as shown in the following table −

Field Name Data Type

EmployeelD AutoNumber

FirstName Short Text

LastName Short Text

Address1 Short Text

Address2 Short Text

City Short Text

State Short Text

Zip Short Text

Phone Short Text


Phone Type Short Text

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.

Let us now add some more fields by clicking on click to add.


Choose Short Text as the field. When you choose short text, Access will then highlight that field
name automatically and all you have to do is type the field name.

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.

Table Design View


As we have already created one table using Datasheet View. We will now create another table
using the Table Design View. We will be creating the following fields in this table. These tables
will store some of the information for various book projects.

Field Name Data Type

Project ID AutoNumber
ProjectName Short Text

ManagingEditor Short Text

Author Short Text

PStatus Short Text

Contracts Attachment

ProjectStart Date/Time

ProjectEnd Date/Time

Budget Currency

ProjectNotes Long Text

Let us now go to the Create tab.


In the tables group, click on Table and you can see this looks completely different from the
Datasheet View. In this view, you can see the field name and data type side by side.
We now need to make ProjectID a primary key for this table, so let us select ProjectID and click
on Primary Key option in the ribbon.
You can now see a little key icon that will show up next to that field. This shows that the field is
part of the table’s primary key.

Let us save this table and give this table a name.

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.

Click Ok and you will see the changes.


An Access database is not a file in the same sense as a Microsoft Office Word document or a
Microsoft Office PowerPoint are. Instead, an Access database is a collection of objects like tables,
forms, reports, queries etc. that must work together for a database to function properly. We have
now created two tables with all of the fields and field properties necessary in our database. To
view, change, insert, or delete data in a table within Access, you can use the table’s Datasheet
View.

 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

AIM: To query data in MS-ACCESS.


A query is a request for data results, and for action on data. You can use a query to answer a
simple question, to perform calculations, to combine data from different tables, or even to add,
change, or delete table data.

 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.

Create Select Query


If you want to review data from only certain fields in a table, or review data from multiple tables
simultaneously or maybe just see the databased on certain criteria, you can use the Selectquery.
Let us now look into a simple example in which we will create a simple query which will retrieve
information from tblEmployees table. Open the database and click on the Createtab.
Click Query Design.
In the Tables tab, on the Show Table dialog, double-click the tblEmployees table and
then Close the dialog box.

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.

Now click Run on the Design tab, then click Run.


The query runs, and displays only data in those field which is specified in the query.
PRACTICAL-6

AIM: To query criteria in MS-ACCESS.


Query criteria help you to retrieve specific items from an Access database. If an item matches
with all the criteria you enter, it appears in the query results. When you want to limit the results
of a query based on the values in a field, you use query criteria.

 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

AIM: To create form in MS-ACCESS.

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 −

 These forms are not connected to an underlying record or data source.


 Unbound forms could be dialog boxes, switch boards, or navigation forms.
 In other words, unbound forms are typically used to navigate or interact with the database
at large, as opposed to the data itself.
Types of Bound Forms
There are many types of bound forms you can create in Access. Let us understand the types −

Single Item Form


This is the most popular one and this is where the records are displayed — one record at a time.
Multiple Item Form
This displays multiple records at a time from that bound data source.

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.

Click on that button to launch the Form Wizard.


On this first screen in the wizard, you can select fields that you want to display on your form, and
you can choose from fields from more than one table or a query.

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.

Multiple Item Form


You may also want to create a specific kind of form. For this, you can click on the More
Forms drop-down menu.
From the menu, you can create a Multiple Items form, a Datasheet form, a Split form, or even
a Modal Dialog form. These are typically bound forms; select the object that you would like to
be bound to that form. This does not apply to the Modal Dialog forms.

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

AIM: To import data from MS-EXCEL to MS-ACCESS.


We will be talking about importing data in Access and what kinds of data you can import using
Access. Normally data is stored in various formats, files, and locations, which makes it hard to
get and use it. If you have data in a spreadsheet, a SharePoint list, or some other format, you can
import it into an Access database with just a few steps, making it much more, easily available in
Access.

 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.

Different Types of Data Access Can Import


To understand what kind of data you can import in the Access data, let us open your database and
go to the External Data tab.
In the import & Link group, you can see the different kind of options available for data import in
Access. Following are the most commonly used data import formats.

 Microsoft Office Excel


 Microsoft Office Access
 ODBC Databases (For example, SQL Server)
 Text files (delimited or fixed-width)
 XML Files
Example
Let us look at a simple example of data importing from an Excel file. Here is the data in Access
file.
To import the data in Access, we first need to open the Access database and then go to the External
Data tab as in the following screenshot.

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.

In Import & Link group, click on the Access option.


Browse the Access database from which you want to import the data and then select the first
option which says Import tables, queries, form etc. Now, click Ok.
In the above dialog box, you can see different tabs for Tables, Queries, Forms etc. from where
you can select what kind of data you want to import.
Let us go to the Reports tab and select any report you want to import; you can also select all the
data by clicking on the Select All button. Let us select Projects and click Ok.
Now, close the dialog box. In the navigation pane, you will see that a new report is added. Let us
open this report and you will see all the data in that report.
PRACTICAL-9

AIM: To export data from MS-ACCESS to MS-EXCEL and text


file.

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 −

 Microsoft Office Excel

 Microsoft Office Access

 ODBC Databases (For example, SQL Server)

 Text files (delimited or fixed-width)

 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.

The following Excel file opens up.


Let us now suppose you want to export data to a text file, on the External Data tab, click on the
Text File.
Specify the export options and click Ok. You will see the Encode dialog box, wherein we want
to export the data in default encoding.

Select the first option and 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.

You will now see that the Text file is open.


Similarly, you can explore other options as well. Thus, it is highly recommended to play with
other import export features too.
PRACTICAL-10

AIM: To create Relationship (one to one) in MS-ACCESS.

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.

Let us now go to the Database Tools tab.

Click on the Relationships option.


Select tblEmployees and tblHRData and then click on the Add button to add them to our view
and then close the Show Tabledialog box.
To create a relationship between these two tables, use the mouse, and click and hold
the EmployeeID field from tblEmployees and drag and drop that field on the field we want to
relate by hovering the mouse right over EmployeeID from tblHRData. When you release your
mouse button, Access will then open the following window −

The above window relates EmployeeID of tblEmployees to EmployeeID of tblHRData. Let us


now click on the Create button and now these two tables are related.
The relationship is now saved automatically and there's no real need to click on the Save button.
Now that we have the most basic of relationships created, let us now go to the table side to see
what has happened with this relationship.

Let us open the tblEmployees table.


Here, on the left-hand side of each and every record, you will see a little plus sign by default.
When you create a relationship, Access will automatically add a sub-datasheet to that table.
Let us click on the plus sign and you will see the information that is related to this record is on
the tblHRData table.

Click on the Save icon and open tblHRData and you will see that the data we have entered is
already here.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy