Databases
Definition
A database is an organized collection of related data
designed and built for a specific purpose.
A database is a collection of information that is
organized so that it can easily be accessed, managed,
and updated.
A Database is a tool for collecting and organizing
information.
Database can store information about people, products,
orders, or anything else.
To create and manage databases, we use Database
Management System Software (DBMS) .
DBMS facilitate the creation, organisation and
maintenance of databases.
Examples of Database Management software include
Microsoft Access, Microsoft SQL Server, Oracle, FoxPro,
Dbase IV, Lotus Approach and MySQL.
Databases use Database Management Systems (DBMS).
MS Access is a Database Management
program that stores information in tables that
are related to each other.
MS Access is a relational database.
In a relational database data is organized in
related tables.
In related tables, one or more fields are linked
to fields in another table.
This link ensures that you can enter only
values that have corresponding entries in the
other table.
Relational database relates, or connects data
in different files by using key fields.
When you use a database, you store your data in
tables.
A table is a database object that you use to store data
about a particular subject, such as employees or
products.
A table consists of records and fields.
A record is also called a row or an instance.
A field is also called a column or an attribute.
A database can contain many tables, each storing
information about a different subject.
Each table can contain many fields of different types
of data, such as text, numbers, dates, currency etc.
Definitions of a few key terms
A table is a collection of related
information that is organized in
columns (fields) that describe an entity
(record).
An entity is a person, place, thing or
idea.
A Record is a collection of information
about a specific entity, such as a
student, applicant, program or project.
If we have pieces of information, on
one subject, we have a record.
Data types
Every field has a data type.
A field's data type indicates the kind
of data that the field stores, such as
text, number, date/time, currency etc.
Table relationships
To connect the data stored in different
tables, you create relationships.
A relationship is a logical connection
between two tables that specifies fields
that the tables have in common.
Keys
Keys are fields that are part of a table relationship.
A key may consists of one or more fields.
There are two kinds of keys:
◦ Primary key
◦ A primary key is a field that uniquely identifies each record
in a table.
◦ A table can have only one primary key.
E.g. ID number, a serial number, or a code, that serves as a
primary key
◦ Foreign key
◦ Foreign key is a field (or collection of fields) in one table
that uniquely identifies a row of another table.
◦ Foreign key is defined in a second table, but it refers to the
primary key in the first table.
◦ A foreign key contains values that correspond to values in
primary key of another table.
◦ A table can also have one or more foreign keys.
Relational database relates or connects data in different
files by using key fields.
Database Design
Step 1: Identify the purpose of your database.
◦ This helps prepare you for the remaining steps.
Step 2: Find and organize the required information.
◦ Gather all types of information you might want to record in the database, such as
product name and order number.
Step 3: Determine the tables you need.
◦ Divide your information items into major entities or subjects, such as
Products or Orders. Each subject then becomes a table.
Step 4: Breakdown the tables into fields (columns).
◦ Decide what information you want to store in each table. Each item
becomes a field, and is displayed as a column in the table. For example, an
Employees table might include fields such as Last Name and Hire Date.
Step 5: Specify primary keys
◦ Choose each table’s primary key. The primary key is a column that is used
to uniquely identify each row. An example might be Product ID or Order ID.
Step 6: Determine the relationships.
◦ Look at each table and decide how the data in one table is related to the data in other
tables. Add fields to tables or create new tables to clarify the relationships, as necessary.
Step 7: Refine the design
◦ Analyze your design for errors. Create the tables and add a few records of sample data.
See if you can get the results you want from your tables. Make adjustments to the
design, as needed.
Advantages of Access
Minimizes duplicate data,
increasing accuracy and
consistency.
Data entry is faster and easier
Data can be viewed and sorted in
many ways.
Information is more secure.
Data can be shared and edited
by several users simultaneously.
Access 2010 user
interface
When you start Access 2010,
Access 2010 has two main
components of user interface —
the Ribbon and the Navigation
Pane.
Access 2010 has an additional
change to the ribbon, and a third
user interface component is the
Microsoft Office Backstage view —
is new in Access 2010.
Three main components of Access 2010 user
interface are:
Ribbon - is the strip of tabs across the top of the
program window that contains groups of
commands.
Backstage view - is the collection of commands
that you see on the File tab on the ribbon.
◦ Backstage view occupies the File tab on the ribbon
and contains many commands.
◦ Backstage view also contains other commands that
apply to an entire database file.
◦ In Backstage view, you can create a new database,
open an existing database and perform many file
and database maintenance tasks.
Navigation Pane - is the pane on the left side of
the Access program window that lets you work with
database objects.
These three elements provide the environment in
which you create and use databases.
Navigation Pane
Navigation Pane - is the pane on
the left side of the Access program
window that lets you work with
database objects.
◦ Navigation Pane is organized by
categories and groups.
◦ You can minimize Navigation Pane, and
you can also hide it.
When you open a database or create
a new one, the names of your
database objects appear in the
Navigation Pane.
Database objects include your
tables, forms, reports, pages,
macros and modules.
Access Database Objects
The following are the objects you can have in an Access
database:
Tables
◦ A Table stores a collection of related information organized in columns
(fields) and rows (records).
Queries
◦ A query is used to extract specific information from your table(s). A Query
takes information from the selected tables and displays a subset of data
that meets your criteria.
Forms
◦ A form is a graphical representation used to enter or view data into a table.
Reports
◦ Presents data from a query or table and places it in neat, organized and
readable form.
Macro
◦ A stored set of commands that can be used to automate database tasks.
Modules
◦ Automates and customizes database operations using visual basic.
Modules are a collection declarations, statements and procedures stored
together as a unit.
Create a database by using a
template
Access provides a wide variety of
templates that can be used to speed
up database creation process.
A template is a ready-to-use
database that contains tables,
queries, forms, and reports needed
for performing a specific task.
A template is a predesigned
database complete with
professionally designed tables,
forms, and reports.
Create a database by using a template
Start Access 2010.
On the New tab of Backstage view, click
Sample Templates.
Under Available Templates, click the
template that you want to use.
In the File Name box, type a file name.
Optionally, click the folder icon next to
the File Name box to browse to a location
where you want to create the database.
If you don't indicate a specific location,
Access creates the database in the default
location that is displayed below the File
Name box.
Click Create.
A blank database
You can start from scratch if you want. This is a good
option if you have very specific design requirements or
have existing data that you need to accommodate or
incorporate
Create a blank database
On the File tab, click New, and then click Blank
Database.
In the right pane, under Blank Database, type a file
name in the File Name box.
◦ To change the location of the file from the default, click
Browse for a location to put your database (next to
the File Name box), browse to the new location, and
then click OK.
Click Create.
◦ Access creates database with an empty table named
Table1, and then opens Table1 in Datasheet view.
◦ The cursor is placed in the first empty cell in the Click to
Add column.
Begin typing to add data, or you can paste data from
another source that has been copied from another
source into an Access table.
Two types of views that can be used in
access are:
◦ Datasheet view and Design view
Datasheet view
In Datasheet view, you can edit fields, add and delete
data and search for data.
Entering data in Datasheet view is designed to be
similar to working in an Excel worksheet.
Datasheet view is a spreadsheet-like view of the data in
a table.
Design view
Opening a table in Design view gives a detailed look at
the table's structure.
Design view provides the most options for defining
fields.
For example, you can find the data type setting for each
field.
Creating a table
Three essential tasks in creating
a table:
◦ Naming the table
◦ Naming the fields (columns)
◦ Selecting data types for each field
(e.g. number, text, dates currency
etc.
Add a table
You can add new tables to an
existing database by using commands
in Tables group on the Create tab.
Create a table, starting in
Datasheet view
In Datasheet view, you can enter
data immediately and let Access build
the table structure behind the scenes.
Field names are assigned
numerically (Field1, Field2, and so on),
◦ and Access automatically sets each
field's data type, based on the data you
enter.
Create a table, starting in Design view
In Design view, you first create the table structure.
Then switch to Datasheet view to enter data.
On the Create tab, in the Tables group, click Table
Design.
For each field in your table, type a name in the Field
Name column, and then select a data type from the
Data Type list.
If you want, you can type a description for each field
in the Description column.
◦ The description is then displayed on the status bar when
the cursor is located in that field in Datasheet view.
◦ The description is also used as the status bar text for any
controls in a form or report that you create by dragging
the field from the Field List pane, and for any controls
that are created for that field when you use the Form
Wizard or Report Wizard.
After you have added all of your fields, save the table:
◦ On the File tab, click Save.
You can begin typing data in the table at any time by
switching to Datasheet view and clicking in the first
empty cell.
Data types
Every field has a data type.
A field's data type indicates the kind
of data that the field stores, such as
large amounts of text or attached files.
A data type is a field property, but it
differs from other field properties as
follows:
You set a field's data type in the table
design grid, not in the Field
Properties pane.
A field's data type determines what
other properties the field has.
You must set a field's data type when
you create the field.
Set or change the primary key
Select the table whose primary key you want to set or
change.
On the Home tab, in the Views group, click View,
and then click Design View.
In the table design grid, select the field or fields that
you want to use as the primary key. To select one field,
click the row selector (row selector: A small box or bar
that, when clicked, selects an entire row in table or
macro Design view, or when you sort and group records
in report Design view.) for the field that you want.
To select more than one field, hold down CTRL, and
then click the row selector for each field.
On the Design tab, in the Tools group, click Primary
Key.
yy
Remove the primary key
Select the table whose primary key you want to
remove.
On the Home tab, in the Views group, click
View, and then click Design View.
Click the row selector (row selector: A small box
or bar that, when clicked, selects an entire row in
table or macro Design view, or when you sort and
group records in report Design view.) for the
current primary key. If the primary key consists of
multiple fields, hold down CTRL, and then click the
row selector for each field.
On the Design tab, in the Tools group, click
Primary Key.
hh