Unleash Your Potential - Namagunga Girls Coding Club
Ms Access
1. A Programme Under the compumitra Series
Wisdom is meaningless until your own experience has given it
meaning and there is wisdom in the selection of wisdom.”
- Bergen Evans Quotes
Creating Database In MS ACCESS
LAB WORK GUIDE
2. OUTLINE
Creating Database in MS Access
Database Creation
Table Creation
Designing Table
Filling Records To The Table
Saving Table
Sorting
Modification Trials
Query
Query Creation
Maintaining Relationship
Doing Query on table
Saving Query
Types of view
Modification Trials
Practice Exercise
Review Summary
References.
3. Opening MS Access
We Are going to use Microsoft Access to create a database,
Which we will attach latter to ASP.NET project.
Go to Start Menu>>All
Programs>>Microsoft Office and then
Click Microsoft Office Access 2003 to
open 'MS Access'
5. Creating Database-1
1st Method
2nd Method
You can create your new database by following one of the two ways.
MS Access Window
Click 'New' button in 'File
Menu' to create a new
database file.
Select ‘New File’ to create a
new database file.
Click on 'Getting Started'
6. Creating Database-2
First step in MS Access is to create a blank
database in which we will add some table later.
Click on 'Blank
Database…'.
• File New Database dialog box will open
•Set your path to C:Learner<student-id>Database
Give 'File name' (Database name)
equal to 'Sale' and then click on
'Create' button.
8. Creating Table In Database
To create a new table in Database
Double Click on 'Create table in
Design view to design table'.
Sale : Database dialog box will open
9. Adding Field Name And Data Type in Table
A particular field will hold which type of value, it is depend on data
type. Eg. Text data type defines field which hold only text value.
Define Field Name and
Data Type here. Field Name and their Data Type are:
ItemId -> AutoNumber
Item_name -> Text
Unit -> Text
Product_Rate -> Number
10. Create Primary Key
Primary key is a key which is used to identify each row uniquely in
the table and we also use it for establishing relationship.
To make an 'ItemId' as primary
key, Right click on 'ItemId' and
select 'Primary Key'
Number
11. Click on 'Save' in 'File'
menu
Saving the Table
'Save As' dialog box will
appear
Give the Table Name equal to
'ItemMaster' and click OK
button
12. Opening Table For Inserting the Records
Click on 'ItemMaster' table to
open table for filling records
13. Inserting the Records in the Table
Insert the records as given in
the table and close it by
Clicking on 'X' button
14. Modification Trails
Go to design view and change the Product_Rate type From
Number to currency and see the result.
You will see that $ sign will be shown with Product_Rate.
Go to design view of the table again and change the Field Size
of the Item_name field '50' to ‘5’ and then see the result on
table by opening it.
Now when you will see that only 5 character of the item name
is shown rest characters are deleted automatically.
16. Sales Table Creation
Create a table by following the same steps
which are used to create ItemMaster table
with following Fields:
ItemId -> Number
Quantity -> Number
Date -> Date/Time
Unit Sale price -> Number
Then save the table and
give it name 'Sales'.
17. Records Insertion in sales Table
Open the 'Sales' table from 'Sale Database' and insert the
records.
Fill the records in the 'Sales' table and close it.
19. Sorting in Ascending order
Sorting is a way of arranging a list into
ascending or descending order.
Select the column and right click on
it, then select 'Sort Ascending'
Now you can see that records are arranged
in the ascending order of Item_name.
In the same way we can sort the column
in descending order.
21. Query Generation: Opening Design View
Select 'Queries' tab from
'Objects'
Select 'Open' or 'Design View' to
relate table.
Right click on 'Create query in Design
View' to open popup menu
By designing query you can access data
according to your choice from the table.
22. Select both tables to relate by
pressing ctrl + mouse left button.
Select tables to relate then Click on
‘Add’ Button.
Query Generation: Add tables to relate
•You can also add the tables one by one.
•After adding the tables, click on 'Close' button.
23. Query Generation: Field Selection
Select 'ItemMaster.*' from Dropdown List
of first column of 'Field' row
This line showing relationship between the
tables.
Select 'Sales.*' from Dropdown List of
second column of 'Field' row
•With the '.*' sign we select all the fields of the table.
•We can also select Fields according to your choice.
24. Query Generation: Viewing SQL Query-1
SQL is an standard language for accessing and
manipulating databases.
To view SQL query for these tables,
Right click on the blank space of
Query Designer and select SQL View
25. Query Generation: Viewing SQL Query-2
SQL ‘Select query’ for the tables, We
can also do some changes according to
our requirements
26. Query Generation: Query Saving
Type Query Name equal to ‘All
Fields’ and then click ‘OK’ button
Open Save As Dialog Box by
pressing Ctrl+S
27. Query Generation: Query Result
Datasheet View is showing fields from both the
tables as we have instructed in the query.
You can modify your query again by going into
query design option of particular query.
To open query, Double click on
'All Fields' query
28. Types of View in MS Access
There are main three types of view in
Query 1-Design View, 2-SQL View and 3-
Datasheet View.
1-Design View
29. Types of View in MS Access
2-SQL View
3-Datasheet View
30. Modification Trails
Arrange the records in the descending order of name in the
queryview.
You will see that when you set the records in the field of one table it
will effect also in the field of other table as there is relationship
between both the table.
Design a query for retrieving ItemId,Item_name from ItemMaster
table and Unit Sale Price from sales table.
Now when you will open your query you will see that only the
selected fields are showing.
Open design view of your ItemMaster table and right click on the field
on which you have created Primary Key. Now select Primary Key
again.
Now you will see that your primary key will be removed. So whenever
you want to change primary key you can do so by this feature. You
can also use ‘Edit’ menu option for the same purpose.
31. Practice Exercise-1
Create a Database Home Expenses. Which have 2
tables namely ExpenseCategory, and Expenses. Save
the Database at "C:Learner<student-id>Database"
location.
Fields Name and their Data Type of
ExpenseCategory table are:
CatId -> AutoNumber
Description -> Text(50 Characters)
SName -> Text(4 Characters)
Fields Name and their Data Type of Expenses table
are:
Date -> Date/Time
ExpensesDetail -> Text(100 Characters)
CatId -> Number
32. Practice Exercise-2
In the ExpenseCategory table fill the data according to the given
Template.
Then create a query which shows the Description, Date
and Expense Detail of the monthly expense where CatID of
ExpenseCategory tabel should be equal to CatID of
Expenses table
33. Review Summary
Creating Database With MS ACCESS.
Designing, Creating and Filling Records in the table.
Fields property setting
Sorting.
Working with queries.
Making Relationships among tables
Concept of primary key.
Some modification trials to enhance knowledge.
35. Ask and guide me at
sunmitraeducation@gmail.com
Share this information with as
many people as possible.
Keep visiting www.sunmitra.com
for programme updates.