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

lab 9.

The document provides an overview of creating and managing databases using MS Access, including defining key concepts such as tables, records, fields, and primary keys. It explains how to create a database, establish relationships between tables, and maintain data integrity through relational links. Additionally, it outlines a lab task for designing a simple database for an e-commerce store, detailing the necessary tables and fields required for customer and item management.

Uploaded by

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

lab 9.

The document provides an overview of creating and managing databases using MS Access, including defining key concepts such as tables, records, fields, and primary keys. It explains how to create a database, establish relationships between tables, and maintain data integrity through relational links. Additionally, it outlines a lab task for designing a simple database for an e-commerce store, detailing the necessary tables and fields required for customer and item management.

Uploaded by

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

Applications of Information and Communication

Technologies Lab
Instructor: Muhammad Ali Haider

MS Access

Introduction to Databases

Creating database

Creating Tables, Data Types, Designer


View

Relationships between tables

Databases
According to Oracle:
“A database is an organized collection of structured information, or data,
typically stored electronically in a computer system.”

Database Management Systems


A database is usually controlled by a database management system
(DBMS).

MS Access
MS Access is also a DBMS, a software which can be used to create relational
databases.
In this lab we will learn about important terms of a database and how to
create one in MS Access.

Create a Database
• Open MS Access, by writing access in search bar.

• Double Clink Blank database, to create a new database. You will be


presented with a screen which asks for the name of the database.
Notice the extension for a database in MS Access is .accdb

• Database has tables in them. Each table stores information about a


specific aspect and has records and fields. Each row in the table is
called a record and all the columns of a record which describe it are
called fields.

• Each record in this table will be of a certain student which will have a
field named id, name, date of birth. Click on the Click to add in order
to add a new field named “name” .

• You are presented with variety of options. These are data types in MS
Access. Just as in any programming language we have primitive
datatypes like int, string, char which represent the type of data in the
variable. In database we similarly have datatypes like Short Text,
Number, Date and Time etc. In this case we want Short Text as we

want to enter name as text. Name the field as “student_name”. Press


Enter.

Add another field this time select the type as Date and time.

• You can see in formatting section the datatype. Format gives you the
option to make it Date or Time.
This is an overview of what each format represent.
• Press Ctrl+ s to save the table. Name it to student_info.
• In order to view how your entire table properties are open Design
View. Right click table and select design view.

• You can build table from designer view as well.


• Double Click the table name again to back to table view and add some
data. You will see that you are not able to add any number in the id

field that is because it is updated automatically as a new record is


added. See its datatype which is “AutoNumber”.

We have seen how to create a table in our database. An important cincept


in databases is primary key.

Primary Key
Each row in the table is called a record. A well-designed database always
has a field (or fields) that holds the unique identifier for each record. This
field(s) is called the Primary Key.
• Often this identifier is a number, but it could be text or a combination
of text and a number
• The important characteristic is that it is unique meaning that each
record has a different one
• In the table you just created, the Primary Key field has the name ID
From
https://courses.cs.washington.edu/courses/cse100/09au/labs/Lab11c.ht
ml

A database has often more than one table. For Example we have the
student_info table. Now we want to store the student registered discipline
in another table.

Linking Tables
Suppose we have three tables now
student_info: id, name, dob Programs:
id, program, details
Enrollments: id, student_id, enrolled_program
All these are linked. The first table holds information on students, the
second table holds information of programs offered by the university. The
last table has a link between both for example student One is enrolled in BS
AI program. This information is present in table Enrollments.
To make these links go to database toolsRelationships
Click Add Tables, a new pane with all the tables in database will open.

Double click each table to add it to the page


You can move around the tables as you like. See the key icon. It represents
the primary key.
We need to make two relationships
• Between student_info id and enrollments student_id
• Between Programs ID and enrolled_program
Select the ID field in student_info and drag it over the student_id field in
enrollments.

An edit relationships popup will appear.


Select enforce refrential integrity and create.
Similarly, drag Programs ID to enrolled_program and select refrential
integrity and press create.

You will have result as

This is a one to many relationship. One to many relationship tells that one
instance in one table can have many relating instances in the other table.
For example one program is BS CS and enrollments can have many students
in BS CS.
We only have three students in student info table now if we try to add a
student e.g id 4 which does not exist in student table to enrollments and try
to save it this will give an error.
Hence maintaining relationships saves the integrity of our data. Data
remains consistent throughout. Why add a student to a program on whom
we don’t have any information about.
In this way large websites and businesses maintain their information
through the use of databases.
Next lecture will cover querying information from databases.

Lab Task Simple Database for e-commerce store:


Suppose you have an e-commerce website. E commerce website is a
platform to sell things online. You want to maintain a database for it.
• A table for saving customer information named “customer_info”.
Fields:
ID-for identifying customer username: a username for the
use email: user’s email password: user’s password so when
the user signs in you can authenticate him.
• A table for storing your item “items” Fields:
ID – for identifying item item_name:
name of item item_price: the price
for item, item_detail: a short detail
for item
• A table wishlist named “user_wishlist” which holds the items a certain
user has added to the wishlist-A user adds item to wishlist as a way to
store it so he can buy it in the future.
Fields:
ID-an id to present the wishlist item user_id: the id of
the user to whom the item belongs to item_id: id of
the item the user added to wishlist
• Make relationship between the three tables customer_info, items,
user_wishlist. As the user will exist in DB to add a certain item to
Wishlist and the item has to exist if it is to be added to the wishlist.
Choosing appropriate data type is also part of the task.

You might also like