lab 9.
lab 9.
Technologies Lab
Instructor: Muhammad Ali Haider
MS Access
Introduction to Databases
Creating database
Databases
According to Oracle:
“A database is an organized collection of structured information, or data,
typically stored electronically in a computer system.”
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.
• 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
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.
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 toolsRelationships
Click Add Tables, a new pane with all the tables in database will open.
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.