Sie sind auf Seite 1von 4

Database

Objectives:

define a single-table database from given data storage requirements


choose and specify suitable data types
choose a suitable primary key for a database table
perform a query-by-example from given search criteria

What is an entity?
An entity is an object of a system which has some data of the system associated with it. In
a relational database each entity can be developed as a table.
Examples:
Product and invoice are entities of a retail store system
Order and Product are entities of a purchasing system
Passenger and Flight are entities of an airline seat reservation system
Student and Class are entities of a student registration system of a school
What is a database?
A database is an organized collection of data.
What is a relational database?
A relational database is a set of tables which are linked through relationships. Therefore
a relational database can be considered as three dimensional.

What is a table?
A table is a set of records about a single entity.
What is a record?
A record is a single instance of an entity and is a row of the table representing that entity.
Each record contains of a set of related fields.
What is a field?
A field is an attribute of an entity and is a column of that table. In a record a field contains a
single piece of data item.
Example:
The table given below represents the entity Student. Name, telephone number and date
of birth are attributes of the Student entity. Therefore Name, Telephone Number and
Date of Birth are fields of the Student Details table.

What is a flat file?


If the data of a particular system resides in a single file, such a file is called a flat file. A flat
file contains a set of records, where each record consists of a set of fields. A flat file can be
considered as two dimensional.

What is database management system?


A database management system (DBMS) is a collection of programs that enables you to
store, modify and extract information from a database. There are many different types of
DBMSs, ranging from small systems that run on personal computers to huge systems that
run on mainframes. The following are examples of database applications:

Computerized library systems


Automated teller machines
Flight reservation systems
Computerized part inventory systems

Why are databases used?


_ They promote data consistency. When data is updated on a database it is up to
date for any application which uses the database.
_ Data duplication is reduced to a minimum since only one copy of each data item
needs to be kept.
_ It is relatively easy to expand the database if some new application is being
considered.
Security of data is easier to monitor and maintain. Data access can be controlled
by database front ends; the actual database will be invisible to all users except
the database administrator
Relational databases
Relational databases were first introduced in 1970 following the work of F. F. Codd, a
researcher at IBM.
Relational databases consist of a number of separate tables which are related (a table is
made up of rows and columns in much the same way as a spreadsheet is structured).
Each table contains a primary (key) field that is also a field in at least one other table. It is
possible to combine data from different tables to produce a
report which only contains the required information.

Relational databases do not need to repeat data, which is one of the problems of flat file
structure (in the example that follows, three flat files would be needed containing repeated
fields of key data since there would be no links connecting each file). Information is stored
in separate tables only connected by the primary (key) field. Other advantages of relational
databases include:
_ faster data retrieval (because of links between tables)
_ easy expansion of the database by adding extra data or new tables
_ the need to change data in only one table all other references to this data will
then also be up to date, resulting in what is known as data integrity.
Tables can also contain foreign keys that relate tables in the database to one another. A
foreign key in one table is a primary key in another.
.

File / Table Design

A database can contain one or more files. A file is a collection of records, each of
which contains information about one person or thing. The data in the records is
separated into fields. A field holds just one item of data. Each field is identified by a
field name.
The following diagram shows examples of a file, records and fields that might be
used in a doctors surgery to keep information about patients. There is a file
containing information about all of the patients. There is one record for each patient.

To create a file you will need to tell the computer what the names of the fields are
that you want to put into each record. You will also have to specify what type of data
can be stored in each field and how much space should be reserved for storing the
data in.

Tables: A table is a collection of related data held in a structured format within a database.
It consists of fields (columns), and records (rows).

Exercise 1: Table 1.1 shows a flat data structure


Employee
Number
A6121
B4142
B5041
A3046
A5211

Employee
Name
Mr. J,Bloggs
Ms. N. Kahn
Ms. R,Spacek
Mr.K.Silva
Mr.N.Choudry

Date joined

Salary ($)

Department

30/01/2000
19/02/2001
04/11/2001
15/12/2003
01/07/2004

18000
25000
19000
40000
25000

Sales
Accounts
Sales
Legal
Accounts

Telephone
number
151 216 009
153 423 111
155 119 110
148 222 333
130 115 100

Table 1.1 Flat file structure for data on employees in a company


a. How many records are there in this section of a database?

b. How many fields are there in each record?

c. Which field contains:


i.
Numeric data only
ii.
Text data only
iii.
Alphanumeric data only?

d. What field is the primary key?

e. In which field has the database been sorted?

f. If the database was sorted in descending order on salary, using the Employee
Number only, what would be the new order of data in the sorted database?

Das könnte Ihnen auch gefallen