Вы находитесь на странице: 1из 31

Introduction to Databases

What is a Database?
A structured collection of similar information
that can be searched and sorted.

A database is made up of files, records and


fields.

What is a Database?

A database is an organised, structured collection of similar


information.

A database can be stored on paper (manual) or on a computer


(electronic).

A program that is used for organising data on a computer is called a database


management system

Data is organised in a database as files, records and fields:

Files.RecordsFields?
Files
A file is a collection of records.
Data in a database is saved on the computer as a data file and contains data on a
particular topic
e.g. a Films data file.
Records
A record is a collection of fields.
A record is a collection of organised data on a particular person or item.
Fields
A field is a single item of information.
A field is part of a record that holds a particular piece of data e.g. Surname.

Sample Fields
Here is a sample record from a telephone directory data file made up of
different fields:
Field

Title

Mr.

Forename

John

Surname

Smith

Address
101
High Street

Record

Town

Ayr

Postcode

Tel. No.

KA7 3KL

01292
262626

What is a Database used for?

Databases are used by many types of businesses and organisations such


as:
Telephone Directory

Police National Computer

Inland Revenue

Driver and Vehicle Licensing Centre

A personal Christmas card list

A mailing list

Data held in a database can be shared between other computer packages


such as a word processor package e.g. Mail Merge.

Advantages of an electronic database?

Information is immediately available.

Records can be processed quickly.

Records can be processed accurately.

All of these are impossible in a


manual system !!!!

Features of a Database?

Databases have many of the features common to a general purpose


package.

There are some special features of a


database:

Create fields

Add and alter records

Search

Sort

Create Fields

The first step on setting up a database is deciding on the fields it requires.

Fields hold the information you want to store.

You can set the size and type of a field.

Size: You can decide how many characters a field can hold e.g.
a Postcode field to hold KA18 3GH would require a minimum of 8 characters as
the space counts as a character!
Type: Fields can hold different types of data:
A text field holds letters.
A number field holds only numbers.
Date and time fields hold numbers formatted into date and time.

Add and Alter Records

The next step is to enter records into the empty database. A new record has
to
be created for each item. e.g.
Record 1

Mr John

Smith

1 Anytown

Scotland

01929 393939

Mrs Susan

Jones

5 The Town

Scotland

01521 447210

Record 2

Search Records

You can run a search on a database for specific information.

You can search on a field (or fields) based on certain conditions you require.
e.g. search for the forenames and surnames of people whose test mark was
greater than 50.

Sort Records

Sorting allows you to organise records into a particular order:

alphabetic

numeric
ascending (1,2,3,4,5)

descending (Z, Y, X, W )

The sort is done by choosing which field the database is to be sorted into
e.g. sort alphabetically by surname.

Additional features of a Database


Reports

any information printed out from a database is a report.

you can search for information, then sort it into an order,


and decide what fields you wish printed out in what order.

this is known as a report definition.

Computed Fields

A computed field (also called a calculated field) can be created in a


database or report.

It carries out a calculation on a field or fields and returns an answer


(similar to a spreadsheet formula in a cell).

Example:
If a database has the fields <Total Pay> and <Total Deductions>, then a third
called <Net Pay> could be set up with the formula:
(=Total Pay Total Deductions).
This is a computed field.

Altering Input/Output formats


You can decide how the information in your database is presented by altering
the
format.
You can change the way the input screen looks and format a report for output.

The position of fields can be rearranged and formatted into a particular order
and layout.

This is useful for designing input screens and producing documents such
as invoices for output.

Keywords
Use of Keywords

When searching for a particular record or part of it, the text that is used for the
search is called a keyword.

It is also known as a search string.

However, care must be taken that the correct keywords are used.

Understanding
Relational Databases

Databases as Collections of Objects


A relational database holds a set of
objects of different types

Tables
Queries
Forms
Reports
Macros

What Database Objects Do


Tables contain the actual data
Forms simplify entering and viewing data
Queries let you view parts of the data
Reports format and print selected data
Macros let you automate command sequences

Tables as Database Objects


One database can hold many tables
The tables hold different kinds of data
Data can be linked between tables
The link between tables is a RELATION
Table A

Table B

What is Related?
We say the two TABLES are related
We really mean certain RECORDS in the
two tables are related
Ability to relate records in multiple tables
gives relational databases their power

Using the Relations


Linked records can be ENTERED using a
data entry form that combines tables and
automates the linkage
Linked records can be viewed together in
queries that show only what you want
Linked records can be combined in
reports

One-to-One Relationship
Table A

Table B

Record 1

Record 1

Record 2

Record 2

Record 3

Record 3

Record 4

Record 4

One-to-Many Relationship
Table A

Table B

Record 1

Record 1A
Record 1B
Record 1C

Record 2

Record 2A
Record 2B

Record 3
Record 4

Record 3A
Record 3B
Record 3C
Record 3D
Record 4A
Record 4B

Many Tables Can Be Linked


Table B

Table A
Table D
Table C

Lookup
Table E

Main Table with Many Fields


Main ID field to link records to other tables
PLUS fields for different pieces of data:
Fields data occurs once in one record
OR
Field is coded present or absent in record
OR
Field has mutually exclusive codes

Subtable to Collect One Topic


Multiple ID fields
Unique ID for each record in subtable
Field for ID to link to main table
Sequence field counts records linked to one case

Fields for one special set of data

text field to hold actual terms, uncoded


code field to hold the codes for the terms
possibly memo field to hold context of terms use
might add other information related to terms use

Two Common Subtable Situations


Partial Code Known

No Code Known Yet

ID fields (numeric)

ID fields (numeric)

Numeric field for Known Codes*

Text field for terms

Text field for Uncoded Terms

Later add numeric field for codes


Could have context memo field

*May link to lookup table that


holds codes

Could have other usage fields


(Could create lookup table later to
hold the code categories)

Lookup Table Holds a Code


ID field is the numeric code
Second field has code names
Third field can hold descriptions of codes
It holds the CODE but not the actual data
Lookup Table
Code 1
Code 2
Code 3

Collection Subtable
Case 1A
Case 1B
Case 1C
Case 2A
Case 2B
Case 3A
Case 3B

Combining in Data Entry Form


Main form holds main table data
form displays one main record at a time

Embedded subforms hold subtable data


form displays multiple records in datasheet view

Lookup table embedded on form

as a dropdown box or scrolling list


view the code names on the list
click on choice and CODE is entered on record
May be entered on main table or a subtable

Where Lookup Code Data Goes


If the lookup is a code for something that
occurs ONCE per record, it goes into a
field on that record.
If the lookup information could occur more
than once you have some choices.
create a fixed number of fields, each with the
same lookup and some way to order them
create a collection sub-table that can accept
multiple rows of data, including the lookup code
in each row, linked to one record.

Вам также может понравиться