You are on page 1of 18

An Introduction to

Databases
Created by: H.R. Lawrence

What is a database?

A collection of data organized in a manner


that allows access, retrieval and use of that
data.

A structure that can be used to store


information about various entities and the
relationships that exist among them

Common Database Terminology


An

entity is an object. A person, place or


thing about which information will be stored.

An

attribute is a property of an entity.

A relation

is an association between entities.


Typically, it is used to maintain links between
entities (tables) using a key.

Types of Keys

Primary- used to uniquely identify each record/tuple in a table. In most


cases it is the indexed key that is used to maintain sequence

Composite is made up of two or more fields

Candidate Any key that can be used as a primary key but was not
chosen to function as such.

Alternate/Secondary Any candidate key that is not selected to be


the primary key

Foreign A primary key in one table that appears in another table but
does not function as the primary key

Database Management System (DBMS)


A software

package that is designed to


manipulate (add, modify, sort, retrieve and
delete) data in a database by an end user.

Examples

of powerful desktop DBMS are:


Microsoft Access, MySQL, Lotus Approach,
FileMaker Pro, and Paradox.

Hierarchical Structure of a Database

Bit is the smallest unit of data that a computer can understand.


Bit, a binary digit can either be a one (1) or zero (0).

Character is a collection of eight (8) bits, also known as a


byte. This can be any letter, number symbol or punctuation
mark.

Field is a column in a database. A field contains a specific


piece of information e.g. name, age, gender and address of a
student

Hierarchical Structure of a Database


cont..

Record (Tuple) is a row in a database. A record is a


unit of information about something e.g. about a
single student in a class.

Files are made up of records. In a school, for


example, you find files on students and teachers

Objects in a Database Management


System
Tables
Forms
Reports
Queries

Creating a Database

Tables

are the building blocks of databases.


A table is a collection of data about a specific
topic, such as person or thing.

Creating a Database cont


Tables

provide easy mechanisms for


adding, changing and deleting data
including the ability to make mass changes
in a single operation.
A separate table should be created for each
entity as this will greatly reduce data entry
errors and increase efficiency.
It is a good idea to design your database
initially using pen/pencil and paper.

Defining the Structure of Tables


In defining the structure of a table you need the following (as a start):
1.

Field Name Each field in the table must have a unique name. For
example, some fields in your school record would be first name, last
name, address, DOB, gender etc.

2.

Data Type This indicates to Access the type of data the field will
contain, such as text, number, date or currency.

3.

Description Access allows you to enter a detailed description of


the field (optional).

4.

Field length (for text) this determines the size of the field.

5.

Field Properties which include data validation check

Example of Table Structure

Data Types use by Microsoft Access


Data Type

Use For

Size

Text

Made up of combination of letters


and numbers. Used with numbers
that will not be used in calculations,
for example, postal and telephone
numbers.

Up to 255
characters. The
user can control
the number of
character.

Memo

Use for long text and numbers such


as notes or descriptions

Up to 65,536
characters.

Number

Data to be used for calculation


except money.

1, 2, 4, 8 or 16
bytes.

Currency

Used to store money. This data type


accurately calculates money

8 bytes

Date / Time

Use to store date and time.

8 bytes

Data Types use by Microsoft Access cont


Data Type

Use For

Size

AutoNumber

Use for automatically sequencing data.

Yes/No (a.k.a.
Boolean or
Logical field)

Use for fields that will contain only one 1 bit


of two values such as yes or no; true or
false and on or off.

OLE Objects

Stores objects such as Microsoft


Applications: Pictures, Graphics,
Sound etc.

Hyperlink

Contain a link to a URL on the Internet.

Look Up
Wizard

If two tables have the same entries the


entry is typed once in the first table and
a look up field is used to pull the
entries from the first to the second.

Up to 1 GigaByte.

Advantages of a database
Quicker

and easier access to data


Allowing sharing of data

TO CREATE A NEW DATABASE FILE


Click

Start, All Programs,


Microsoft Office, Microsoft Office Access
2003
Select Blank Access Database, Click OK
Choose your storage location (
Enter

the File Name in the textbox, and then


click Create

TO DEFINE THE STRUCTURE OF A


TABLE

Click Tables in the Objects pane


Double click Create table in Design view OR click once and then press the
Enter Key
Enter the first Field Name in the Field Name Column, and then press the TAB
key
Click on the drop down list; select the Data Type (Text is the default) by clicking
on it.
Press the TAB key then enter the description (if given one)
[IF THE DATA TYPE IS TEXT delete the 50 at Field Size and enter the value
given]
Repeat from step 3 to enter remaining fields.
To select a Primary Key, Click in the respective row, Click Edit, Primary Key.
Click File then Save, enter the table name and then click OK.
Close the design view window.

TO POPULATE (ENTER DATA INTO) A


TABLE
Click

on Tables in the object pane (the


names of existing table(s) will be displayed)
Double click the name of the table you want
OR click once and then press the Enter Key
Enter the relevant data for EACH record
under the respective Field Names

You might also like