Final DBMS
Final DBMS
P Madal’s
Theory: -
In this Assignment, we will be covering the basic process of starting Access and creating a
database. This practical Assignment 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.
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.
Theory: -
In this Assignment, we will be covering the how to create tables using MS ACCESS different
ways. For that 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.
First of all you need to go in create database in create database you will see a blank table name
as table1
After that right click on table1 you will see table design view from that you will fill necessary
filed which you want to add in table with its name and data type
Sometimes 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.
After the right click on table1 you will see table design view from that you will fill necessary
filed which you want to add in table with its name and data type but before that you will see
the window in that you need to put up the table name
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.
After fill up all the required information your table will be successfully created.
Assignment Question:
Q. Create table in MS ACCESS about Students Fess information (Attach Printout output).
Theory: -
In this Assignment, 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
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.
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.
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.
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.
Q. Import the Students Result Analysis Data from Excel to MS ACCESS (Attach Printout
output).
Theory: -
In this Assignment, 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.
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.
Assignment Question:
Q. Export Students Fess Details table form MS ACESS to MS Word(Attach Printout output).
Theory: -
In this Assignment, we will learn how to implement selection, projection, Cartesian product
query apply on data/table from Access.
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 data based on certain criteria, you can use the Select
query. 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 Create tab.
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.
The query runs, and displays only data in those fields which is specified in the query.
For example, if you were to join two tables without any kind of qualification or join
type, you would get a Cartesian product.
Imagine you wanted to show a permutation of all record instances for date, month and year
which have been stored in separate tables where the ‘Days‘ table contained 31 records (for each
day of a maximum month), the ‘Months‘ table for each month of the year (12 records) and the
‘Years‘ tables containing as many years as needed for the database process (which in this
example I’m using 6 records (2010 to 2015).
Now the total product of all records between the three tables should yield 2,232 assuming
there are 31 days for each month (which of course that’s not true!) but keeping it simple, this
total is the product of using the formula of 31 x 12 x 6 = 2,232.
Notice there are no joins of any description and the more non-related tables there are the
bigger the product effect.
In reality, this example is useless unless of course you add filters to exclude months that end
with either 28, 29 or 30 days which will mean a way to suppress non valid dates
Assignment Question:
Theory: -
In this Assignment, we will learn how to implement union, insertion, difference query apply on
data/table from Access.
Union:
This assignment gives the importance and the use of Union Queries and also gives steps to
effectively use it to get combined results.
Suppose a user has an MS Access database with two unrelated tables, one with client data and
another with customer data. We assume that both these tables will have a field for contact
information. Now if the user wants to see contact information in one view of both these tables,
he will have to use the Union Query.
Union Query is used for selecting and retrieving information from more than one table in a
single go. To do this, the user needs to select the query from each table, which will retrieve the
data and then combine the result, by creating the union query.
Step 2: Select the Table with the fields that you want to add from the Show Table. The table
will be automatically added on your Query Design Window.
Step 4: Now select the fields, from the Query Design Window.
Ensure to select the same order and number of fields that you are adding to the other select
query. Also, check whether the data types in each field are compatible with each other or not.
Step 5: Now add the criteria in the field with the appropriate expressions.
Step 6: Run the select query, and recheck its output. Open Design tab, from Results group,
and click Run.
Step 9: Repeat the procedure for each select query that the user wants to combine.
Access displays the SQL view object tab while hiding Query Design Window. And at this time
the SQL view Tab is empty.
Step 1: Select the tab of first select query that the user wants to combine as a union query.
Step 3: Copy and insert the SQL statement for select query. Now open the tab, which you
created in the above steps for ‘Creating a union Query’.
Step 4: Paste the SQL statement in SQL View Object in the union query.
Step 5: Delete the semicolon (;) placed at the end of a select query in its SQL statement.
Step 6: Press Enter so that the cursor moves down one line, then type UNION in the new line.
Step 7: Select the tab for next query that the user wants to combine in Union Query.
Step 8: Repeat all the steps till 5, until the user has copied and pasted all the SQL statements
for select query in Union Query’s SQL View Window. Don’t delete the semicolon from the last
SQL statement or query.
The results of the user’s query will automatically appear on your screen in a Datasheet view.
Insertion:
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.
Similarly, add some data in the second table as well as shown in the following screenshot.
Theory: -
A database is a collection of tables of data that allow logical relationships to each other. You
use relationships to connect tables by fields that they have in common. A table can be part of
any number of relationships, but each relationship always has exactly two tables. In a query, a
relationship is represented by a Join.
What is Join
A join specifies how to combine records from two or more tables in a database. Conceptually, a
join is very similar to a table relationship. In fact, joins are to queries what relationships are to
tables.
The following are the two basic types of joins that we will be discussing in this chapter −
Inner Join
The most common type of join is an inner join which is also the default join type in
Microsoft Access.
Inner Join will display only the rows or records where the joined fields from both tables
are equal.
This join type looks at those common fields and the data contained within. It only
displays the matches.
Outer Join
An outer join displays all rows from one table and only those rows or records from the
other table where the joined fields are equal.
Let us now understand Left Outer Join and Right Outer Join −
You can choose the table that will display all rows.
You can create a Left Outer Join which will include all the rows from the first table.
You can create a Right Outer Join that will include all the rows from the second table.
Let us now go to the Create tab and create a query from the Design View. Select tblProjects and
tblTasks and close the Show Table dialog box as in the following screenshot.
When we create this query in Microsoft Access, Access is taking this relationship from
the relationships we have created.
By default, it is creating what's known as an Inner Join between these two fields,
between these two tables, and that is how it is relating this information together from
these two tables.
It is showing us only the matches, so when we run this query, there are a lot of other
projects listed in tblProjects that do not appear as part of our records set in this query,
and that is because of how these two tables are joined together, through that Inner
Join, which is again, that default Join for any query.
However, if you want to alter the relationship, Let us say you want to create an outer join, or in
other words, show all of the projects from tblProjects, every single record that is in that table,
along with all of the tasks from tblTasks — Open join properties; we can do this simply by
double-clicking on the relationship line.
The left column name and the right column name and the first radio button is to only
include rows where the join fields from both tables are equal and that is the inner join
and that is what is selected by default when creating relationships, when creating a join
in the query, but, you can change it.
We have two other options as well; we can include all records from tblProjects, and only
those records from tblTasks where the joined fields are equal and this one is Left Outer
Join.
We have a third option, include all records from tblTasks and only those records from
tblProjects where the joined fields are equal and this one is Right Outer Join.
Those are the different types of joins you can create easily from the Design View. Let us select
the second option, which is Left Outer Join, and click Ok.
When you look at the relationship line, you will see a little arrow pointing towards Project ID in
tblTasks. When you run this query, you will see the following results.
In the Join Properties dialog box, select the third option which is for the Right Outer Join and
click Ok.
Self-join is another type of Join. A Self-join relates matching fields from within the same table.
For example, look at the employee's table with a supervisor field, which references the same
kind of number stored in another field within the same table — the employee ID.
If we wanted to know who Kaitlin Rasmussen's supervisor is, we will have to take the number
stored in that supervisor field and look it up within the exact same table in that employee ID
field in order to know that Charity Hendricks is the supervisor.
This table is not the ideal structure for a relational database because it's not normalized.
If we have a situation where we want to create a query that just lists the employee names
alongside the names of their supervisors, there is no easy way we can query that unless we
create a Self-join.
To see a Self-join, create a table with the following fields and enter some data.
Now, add the first name and last name for our employees.
We have created another copy of the same table in this query view. Now, we need to create Self-
join. To do that, click on Supervisor in tblEmployees table and hold the mouse button and drop
it right on top of the EmployeeID in that copied table — tblEmployees_1. Then, add the first
name and last name from that copied table.
It displays the names of the employees alongside the names of their supervisors. And, this is
how you create a Self-join in Microsoft Access.
Assignment Question:-
Q. Crate 2 tables and show the relationship between 2 tables (Attach Printout output).
Theory: -
In this tutorial we learn about how to design/Generates Forms and adding new record in MS-
Access. There are many ways to add data to a Microsoft Access Table. Using Forms is the
easiest way to build your database. If you use Microsoft Access, you already know the many
ways to add data to your databases. Most users use the table method as that’s the easiest way
to view and add new data. However, the problem with that is you need to go through your
existing data before you can add new. There are also chances of accidentally modifying your
existing data with the table method. Luckily, Access has something called Forms that lets you
work on one entry at a time to add new data to your tables. Forms are an easy way to both edit
as well as store new items in your tables, and you should start using them if you don’t already.
Before you can create a form in Microsoft Access, you should have created at least one table in
your database. This is the table that you’ll add data to from your newly created form.
Once your table is ready with some columns in it, follow these steps to add a form for it:
1. Select your database table by clicking on it in Access.
2. Click the Create tab at the top, find the Forms section, and select Form
3. Microsoft Access will create a new form with all the columns of your table as fields.
4. You can now edit and also add new data to your table with this form. Use the pagination at
the bottom to go through your table records.
5. Click the Save icon at the top-left corner to save your newly created form.
6. Enter a descriptive name for your form and click OK to save it.
The above method creates a form with all your table’s columns added to it. If you don't want to
use all the columns, create a blank form first, and then select the fields you want to include.
You can add fields to your blank form from any of your tables within the same database. You
can also change the order of your fields in your form with this method.
1. In Access, click the Create tab at the top and select Blank Form
2. Start adding fields. On the right, select the table that you want to add fields from, then
double-click on individual fields to add them to your form.
When you update your tables and you add new columns to them, those new columns won’t
automatically be added to your forms. So you can’t add data into those new columns until you
update your forms. In Access, you can add new fields to your existing forms anytime.
1. Right-click on your form in Access and select Layout View. This opens the form in the
layout view.
2. Click the Design tab at the top and select Add Existing Fields from the Tools section.
This will let you add new fields to your form.
3. On the right, you will see all the fields that your tables currently have. Double-click on
a missing field and it will be added to your form.
Theory: -
In this chapter, we will be covering the basics of reports and how to create reports. Reports
offer a way to view, format, and summarize the information in your Microsoft Access database.
For example, you can create a simple report of phone numbers for all your contacts. A report
consists of information that is pulled from tables or queries, as well as information that is
stored with the report design, such as labels, headings, and graphics. The tables or queries
that provide the underlying data are also known as the report's record source. If the fields that
you want to include all exist in a single table, use that table as the record source. If the fields
are contained in more than one table, you need to use one or more queries as the record
source.
Example
We will now take a simple example to understand the process of creating a very simple report.
For this, we need to go to the Create tab.
Before clicking on the Report button to create a basic report, make sure the proper query is
selected. In this case, qryCurrentProjects is selected in your navigation pane. Now click on the
Report button, which will generate a report based on that query.
Theory: -
In this Assignment, you'll learn how to use the Report Wizard to create complex reports. While
using the Report command is a quick way to create reports from the current object, it's not as
helpful if you want to create a report with data from multiple objects. The Report Wizard makes
it easy to create reports using fields from multiple tables or queries. It even lets you choose h
Similar to the Form Wizard; the Report Wizard walks you through a series of decisions in order
to build a report. To create a report using the Report Wizard, follow the steps below.
This feature works the same in all modern versions of Microsoft Access: 2010, 2013, and 2016.
1. On the Create tab in the Reports group, click Report Wizard. The wizard startsow your
data will be organized.
2. From the Tables/Queries drop-down list, select the table (or query) to base the report
on. The fields for the selected table load in the Available Fields list box.
3. Move the fields to include on the report from the Available Fields list box to the Selected
Fields list box. To do so, double-click a field name to move it or highlight the field name
and click >. To move all fields at once, click >>.
5. To group records on the report by a particular field, highlight the field in the list box
and click >.
6. Add more grouping levels if desired. You can use the arrows to change the order of the
grouping levels if needed.
8. In the first drop-down list, select the field to sort records by. By default, records will be
sorted in ascending order by the field you select. If you want to sort in descending
order, click the Ascending button to change its label to "Descending".
9. You can specify up to four levels of sorting. When you finish specifying sorting options,
click Next >.