Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 113

Database Systems

A guide to
producing a
fully functional
RDBMS
How Can this Presentation
Help Me?
If you work through this presentation use the terminology
quoted and produce all the diagrams and documentation
mentioned throughout this presentation, you will have
succeeded in meeting most of the requirements necessary
to produce a successful report on the analysis, design and
implementation of a Relational Database.

Do not move on from one


section to the next until you
fully understand and can apply
the concepts described in this
presentation
Contents
Theory and terminology
The Analysis Phase
• Requirements Definition
• Functional Dependency & Relationships
• Normalisation
• Entity Relationship Diagrams
• Data Dictionaries & Data Types
• Functions [Input, Processes & Outputs]

The Design Phase


The Implementation Phase
Some Terminology

• Data – A collection of raw facts and


figures

• Information – Final product created from


the raw data after processing
• Database – A collection of related
information organised in a
structured way to allow easy
retrieval of any one item
Elements of a database
Table – A complete set of data. Also
known as an entity or relation
Record – One row of the table
Field – One column of the table. Also
known as an attribute

Types of Database
Flat file Database – Single table
Relational Database – Multi table
Flat-file Database – Single table
A telephone directory is an
example of a flat file database

Problems with flat-file databases

• Redundant Data
Data is repeated and hence stored many times. This
wastes disk space and slows down query time.

• Typographical Errors
Greater likelihood of errors when data is being entered.
Problems with flat-file databases

• Updating Data
Every occurrence of a piece of data will have to be
updated if its value changes

• Modifying Data
If a record is deleted this may destroy all reference to a
particular piece of data

To overcome these problems it is better to store data


in multiple tables i.e. a Relational database
Characteristics of a
relational database

• Data is stored in a set of tables

• Tables are joined by relational links

• Reduces duplication of data in database


- Normalisation

• Allows greater flexibility and efficiency


Relational Database – Multi table
The data is stored in multiple tables. This is the most
common way of keeping a computerised database

• Each table must have a unique reference for each


record which is called the Primary key
• Replicating these into other tables creates the
Foreign key
• These foreign keys form the Relationships that link
the tables together
Relational Database – Multi table

• Redundant Data
The disk space required to store data is reduced and
queries can be performed more quickly.

• Typographical Errors
As data is only entered once the chances of these errors
occurring are greatly reduced..
Relational Database – Multi table

• Updating Data
Data need only be updated once as it would only have
been entered once

• Modifying Data
Problems of the kind mentioned earlier disappear. New
records will simply have their attributes added to the
relevant table
Database Management System [DBMS]

• DBMS
A computer program or collection of computer programs
that provides the necessary tools to create and
manipulate the data in a database

• RDBMS
Relational Database Management Systems are used to
create and manipulate relational databases e.g.
- Microsoft Access
- Oracle
- Lotus Approach
Database Systems -

Construct a data model of an


existing, non computerised
system

THE ANALYSIS PHASE


Database Systems

Analysis Phase

• Requirements Definition
• Normalisation
• Entity-Relationship Diagrams
• Data Dictionaries
• Functions
Database Systems

Analysis

• Requirements Definition
• Normalisation
• Entity-Relationship Diagrams
• Data Dictionaries
• Functions
Requirements Definition

When we normalise any type of database system we


need to know what the data in the system means.
Therefore we either have to talk to the people who
use the existing system or we have to be supplied
with very detailed information about how the
system works and the data stored within it.

The following slide shows an example of some


current data.
Below this are listed some questions that help
establish the requirements of the new system.
Can you think of anything else the analyst might
ask?
Requirements Definition
Salesperson Salesperson Sales Customer Customer Warehouse Warehouse Sales
Number Name Area Number Name Number Location Amount
3462 Walters West 18765 Delta Systems 4 Fargo 13540
18830 A.Levy & Sons 3 Bismark 10600
19242 Rainer & Co. 3 Bismark 9700
3593 Dryne East 18841 R.W.Flood Inc. 2 Superior 11560
18899 Seward Systems 2 Superior 2590
19565 Stodola's Inc. 1 Plymouth 8800

• Does each salesperson have their own sales area?


• Does each customer deal with only one salesperson ?
• Does each customer only receive goods from one warehouse?

The answer to these questions will influence how we structure


the database system.

The answer to these questions and others make up the


Requirements Definition
Database Systems

Analysis

• Requirements Definition
• Normalisation
• Entity-Relationship Diagrams
• Data Dictionaries
• Functions
Functional Dependency

Functional dependency means that there must be only a one-


to-one dependency for each attribute mapped from a
primary key to that attribute.

It defines a relationship in which the existence of one


entity/attribute is entirely dependent on the existence of
another (one-to-one).

For example, the engine number of a car [Primary Key] can


only have engine capacity as an attribute of that key creating
Functional Dependency
BUT
A particular engine capacity can be associated with the
engine numbers of many makes of car. This does not give rise
to Functional Dependency
Functional Dependency - Practical Example

Order Number is the primary key.

The value for each attribute of SALES,


except Item Price, depends upon the value
of the primary key.

All attributes of SALES, except Item Price,


are Functionally Dependent on the
primary key

Item Price is Functionally Dependent on the


the attribute Item
Relationships
Having established a definition for the term Functional
Dependency we now need to explore the different types
of relationships that can exist between attributes in
different entities:

There are 3 types of relationships that can exist:

• One to One Relationships


• One to Many Relationships
• Many to Many Relationships

Now lets take a closer look at each of these on the next


slides
Entity Relationships

One-to-one
A blind person owns a guide
dog which is exclusively
theirs.

J. Smith Rover

B. Jones Pippa

A. Gray Patch
Entity Relationships

One-to-many
A doctor may have many
patients, but a patient is
assigned to only one doctor.

Grant
Dr Ache Allan
Mark
Dr Payne Jane
Amy
Entity Relationships

Many-to-many
A film may have many stars
and each star may act in
many films.

Star A
Film X
Star B
Film Y
Star C
Important Note:

An RDBMS system cannot produce a robust solution


if two or more of the entities have a many to many
relationship

To overcome this problem it is necessary to


introduce another entity thus creating One to
Many relationships between itself and the offending
entities

This can become a common occurrence when you are


working with larger and more complex database
systems
Now you should have the tools and understanding you
require in order to normalise the data in order that a
solution can be produced using an RDBMS [Relational
Database Management System]

Please take your time when working through the next


part of this presentation and revisit it again and
again until you are completely comfortable with the
concepts involved

Normalisation of the data is perhaps the single most


important aspect of developing a robust solution to
any database problem!
Normalisation
• Normalisation is a 'fancy' term for a
set of rules, designed to make sure that
a database is organised in the best way
possible

• This allows the data to be processed more


efficiently and any query to be processed.

• These rules depend on relationships being


established between the entities to create
a functional dependency between them.
The normalisation process involves:

• Finding and grouping together all the


entities and their attributes.
• Removing repeating groups of data.
– This is another way of saying that there is no point in
storing a persons' name and details etc. in many
different places within a database.
• Providing unique keys for each entity in the
database system.
– You need to have a way of making sure that when you
delete 'Paul Smith' from the Transactions entity that it
is the correct person.
The Three Major Stages of Normalisation:

• First Normal Form


– 1NF is the first level of normalisation. An entity (table) is
in First Normal form if it contains no repeating attributes
(fields) or groups of attributes.
• Second Normal Form
– An entity is in 2NF if no attribute (not part of the primary
key) is dependent on only part of the primary key. This
only applies to entities with concatenated primary keys.
• Third Normal Form
– An entity is in 3NF if all attributes are entirely dependent
on the primary key and not on any attribute that is not
part of the primary key.
To produce a set of entities in First Normal
Form (1NF):

• Remove repeating (multiple) groups within the primary


entities (tables) so that each record (row) within the entity
is the same length.

• Repeating groups then become new entities, linked together


by a one-to-many relationship.

• Relationships are created by including a primary key from


one entity as a foreign key in another entity
Charlie’s Baker Shop
Order Acc. Customer Address Date Item Qty. Item Total
No. No. Price Cost
7823 178 Daisy's Café 27 Bay Drive, 16/7 Bakewell 20 0.15 12.35
Cove Tart
Danish 13 0.20
Pastry
Apple Pie 45 0.15

4633 526 Smiths 12 Dee View, 16/7 Butteries 120 0.20 24.00
Aberdeen
2276 167 Sally's 3 High Street, 17/7 Apple Pie 130 0.15 56.50
Snacks Banchory
Cherry 100 0.18
Pie
Steak Pie 30 0.50

Meringue 20 0.20
Pie
1788 032 Tasty Bite 17 Wood Place, 18/7 Apple Pie 15 0.15 7.50
Insch
Danish 50 0.20
Pastry
Charlie’s Baker Shop
Order Acc. Customer Address Date Item Qty. Item Total
No. No. Price Cost
7823 178 Daisy's Café 27 Bay Drive, 16/7 Bakewell 20 0.15 12.35
Cove Tart
Danish 13 0.20
Pastry
Apple Pie 45 0.15

4633 526 Smiths 12 Dee View, 16/7 Butteries 120 0.20 24.00
Aberdeen
2276 167 Sally's 3 High Street, 17/7 Apple Pie 130 0.15 56.50
Snacks Banchory
Cherry 100 0.18
Pie
Steak Pie 30 0.50

Meringue 20 0.20
Pie
1788 032 Tasty Bite 17 Wood Place, 18/7 Apple Pie 15 0.15 7.50
Insch
Danish 50 0.20
Pastry
Charlie’s Baker Shop

Orders

Items Purchased
Charlie’s Baker Shop

Orders

Items Purchased
Charlie’s Baker Shop
Orders Table:

Order No. can be used to uniquely identify each record and can
therefore be made the primary key.

Orders (Order No.


Acc. No.
Customer
Address
Date
Total Cost)
Charlie’s Baker Shop
Items Purchased Table:

No one attribute can be used to


uniquely identify a record.

Concatenated key is required

Order No. and Item together can


uniquely identify a record.

Items (*Order No.


Purchased Item
Quantity
Item Price)
Charlie’s Baker Shop
First Normal Form

Orders (Order No. Items (*Order No.


Acc. No. Purchased Item
Customer Quantity
Address Item Price
Date
Total Cost)
The Three Major Stages of Normalisation:

• First Normal Form


– 1NF is the first level of normalisation. An entity (table) is
in First Normal form if it contains no repeating attributes
(fields) or groups of attributes.
• Second Normal Form
– An entity is in 2NF if no attribute (not part of the primary
key) is dependent on only part of the primary key. This
only applies to entries with concatenated primary keys.
• Third Normal Form
– An entity is in 3NF if all attributes are entirely dependent
on the primary key and not on any attribute that is not
part of the primary key.
To produce a set of entities in Second Normal
Form (2NF):

• Test for dependency by testing each particular attribute in


turn to check that it can be uniquely identified by making
use of all the primary key. This test need not be completed
unless you have at least one table which requires a
concatenated Primary Key

• Remove all partially dependent attributes to a new entity.

N.B. – A concatenated key occurs when you need two


fields together in order to uniquely identify a record
Charlie’s Baker Shop
First Normal Form

Orders (Order No. Items (*Order No.


Acc. No. Purchased Item
Customer Quantity
Address Item Price)
Date
Total Cost)
Charlie’s Baker Shop

Orders Table:

Because this entity has a single attribute as the primary key


there can be no partial dependencies and therefore the entity
is already in 2NF.
Charlie’s Baker Shop
(2NF Step 1)

Items Purchased Table:


Primary key is Order No. and Item

Test for dependency by testing each


particular attribute.

Primary Key Attribute Functionally Dependent?


Charlie’s Baker Shop
(2NF Step 1)

Items Purchased Table:


Primary key is Order No. and Item

Test for dependency by testing each


particular attribute.

Primary Key Attribute Functionally Dependent?

Order No Quantity YES


Item Quantity is functionally dependent
on Order No. and Item.
Charlie’s Baker Shop
(2NF Step 1)

Items Purchased Table:


Primary key is Order No. and Item

Test for dependency by testing each


particular attribute.

Primary Key Attribute Functionally Dependent?

Order No Quantity YES


Item Quantity is functionally dependent
on Order No. and Item.
Order No Item Price NO
Item Item price is functionally dependent
Item, but not on Order No. and Item
Charlie’s Baker Shop
(2NF Step 2)

Remove any partially dependent attributes to a new entity


Charlie’s Baker Shop
(2NF Step 2)

Remove any partially dependent attributes to a new entity

Part Order Price List


Charlie’s Baker Shop
(2NF Step 2)

Create a relationship between the tables


and assign Primary Keys

Part Order Price List


Primary Key: Order No. Primary Key: Item
and *Item
Charlie’s Baker Shop
Second Normal Form

Orders (Order No. Price List (Item


Acc. No. Item Price)
Customer
Address
Date Part Order (*Order No.
Total Cost) *Item
Quantity)
The Three Major Stages of Normalisation:

• First Normal Form


– 1NF is the first level of normalisation. An entity (table) is
in First Normal form if it contains no repeating attributes
(fields) or groups of attributes.
• Second Normal Form
– An entity is in 2NF if no attribute (not part of the primary
key) is dependent on only part of the primary key. This
only applies to entries with concatenated primary keys.
• Third Normal Form
– An entity is in 3NF if all attributes are entirely dependent
on the primary key and not on any attribute that is not
part of the primary key.
To produce a set of entities in Third Normal
Form (3NF):

• Test each attribute in turn to check for dependency on the


primary key.

• Remove all transitive dependencies to a new entity.


– A transitive dependency is where an attribute is
dependent on another attribute (or attributes) that is
(are) NOT the primary key
Charlie’s Baker Shop
Second Normal Form

Orders (Order No. Price List (Item


Acc. No. Item Price)
Customer
Address
Date Part Order (*Order No.
Total Cost) *Item
Quantity)
Charlie’s Baker Shop - 3NF Step1

Test for
dependency

Primary Key Attribute Trasnsitive Dependency


Charlie’s Baker Shop - 3NF Step1

Test for
dependency

Primary Key Attribute Trasnsitive Dependency


Order No. Acc.No. YES: Acc.No can be found if we know either
Customer or Address
Charlie’s Baker Shop - 3NF Step1

Test for
dependency

Primary Key Attribute Trasnsitive Dependency


Order No. Acc.No. YES: Customer can be found if we know either
Acc.No. or Address
Order No. Customer YES Customer can be found if we know either
Acc.No. or Address
Charlie’s Baker Shop - 3NF Step1

Test for
dependency

Primary Key Attribute Trasnsitive Dependency


Order No. Acc.No. YES: Customer can be found if we know either
Acc.No. or Address
Order No. Customer YES Acc.No. can be found if we know either
Customer or Address
Order No. Address YES Address can be found if we know either
Customer or Acc.No
Charlie’s Baker Shop - 3NF Step1

Test for
dependency

Primary Key Attribute Trasnsitive Dependency


Order No. Acc.No. YES: Customer can be found if we know either
Acc.No. or Address
Order No. Customer YES Acc.No. can be found if we know either
Customer or Address
Order No. Address YES Address can be found if we know either
Customer or Acc.No
Order No. Date NO Dependent on Order No.
Charlie’s Baker Shop - 3NF Step1

Test for
dependency

Primary Key Attribute Trasnsitive Dependency


Order No. Acc.No. YES: Customer can be found if we know either
Acc.No. or Address
Order No. Customer YES Acc.No. can be found if we know either
Customer or Address
Order No. Address YES Address can be found if we know either
Customer or Acc.No
Order No. Date NO Dependent on Order No.

Order No. Total Cost NO Dependent on Order No.


Charlie’s Baker Shop - 3NF Step2
Remove transitive dependencies to a new entity
Charlie’s Baker Shop - 3NF Step2
Remove transitive dependencies to a new entity

Orders Customers
Charlie’s Baker Shop - 3NF Step2

Create a relationship between the tables


and assign Primary Keys

Orders Customers

Primary Key: Primary Key:


Order No. Acc.No.
Charlie’s Baker Shop
Third Normal Form

Customers (Acc. No. Orders (Order No.


Customer *Acc. No.
Address) Date
Total Cost)

Part Order (*Order No.


Price List (Item *Item
Item Price) Quantity)

Normalisation Complete
Normalisation -

1. Remove repeating groups to create a new entity


2. Create a relationship using one of the attributes
that are left [Usually the primary key]
3.‘Check out’ entities with concatenated keys. If any
attribute is not fully dependent on both parts of the
primary key remove it to create a new entity.
4. Create a relationship using one of the attributes
that are left [Usually the primary key]
5.‘Check out’ every entity. If any attribute is
dependent on any attribute other than the primary
key, remove it into a new entity.
6. Create a relationship using one of the attributes
Database Systems

Analysis

• Requirements Definition
• Normalisation
• Entity-Relationship Diagrams
• Data Dictionaries
• Functions
Entity - Relationship Diagrams

• E-R diagrams show the structure of the data to be


modelled.
• They are a convenient method for representing
the relationships, entities and attributes in a
system.
• This is done by illustrating a system with a
diagram to produce a detailed specification for
each entity and the attributes within them.
Symbols used in an E – R diagram

ENTITY Entity – a collection


of data [table]

Attribute – a data item


ATTRIBUTE in an entity
[field]
Symbols used in an E – R diagram

Key Attribute – a data item


KEY ATTRIBUTE
which makes up
the primary key or part
of it.

Relationship – a
description of the
RELATIONSHIP link between two
entities.
Simple Examples

1. A blind person owns a guide dog

1 1
Blind Person owns Guide Dog

2. A doctor treats many patients

1 M
Doctor treats Patients
Simple Examples

3. A film may have many stars and


each star may be in many films.

M N
Film has Stars
Charlie’s Baker Shop
Third Normal Form

Customers (Acc. No. Orders (Order No.


Customer *Acc. No.
Address) Date
Total Cost)

Part Order (*Order No.


Price List (Item *Item
Item Price) Quantity)
1. Determine the relationships between the
entities.

1 M
Customers places Orders

1
Charlie’s
contains
Baker Shop
M
1 M
Price List has Part Order
Charlie’s Baker Shop
Third Normal Form

Customers (Acc. No. Orders (Order No.


Customer *Acc. No.
Address) Date
Total Cost)

Part Order (*Order No.


Price List (Item *Item
Item Price) Quantity)
Order No
2. List the attributes alongside *Acc. No

each entity Total Cost


Date
1 places
M
Customers Orders

Acc.No 1
Customer Charlie’s
contains
Address Baker Shop
M
1 M
Price List has Part Order
*Order No
Item
*Item
Item Price
Quantity
Database Systems

Analysis

• Requirements Definition
• Normalisation
• Entity-Relationship Diagrams
• Data Dictionaries
• Functions
Data Dictionary
• A data dictionary is a database about a
database and is often called metadata
[data about data]
• It is created at the analysis stage to provide a
record of the attributes and their properties:
- Data type
- Required [or not] I.e. Can this field be left
blank ?
- Range
- Format
• When the database is up and running it acts as
a useful reference
Data Types

Text
A text attribute only stores letters from the
standard 26 character alphabet
Number
Used to hold numeric data. Remember to show the
range of numbers to be stored [ Use common sense]
Text and Number
Used for alphanumeric data e.g. An address that
may contain a house number and street name.
Data Types

Date
Dates can be laid out using various formats. Two
common formats are short (dd/mm/yy) or
(dd/mm/yyyy) and long (month day, year)
Time
Various formats can be used here. A time of
day, a duration, 24-Hr clock, am/pm etc.
Boolean
These are binary values only having two states.
True/false, yes/no or off/on.
Data Types

The data types and formats used at this


stage will be general and will be mapped
on to those available in the RDBMS
[Relational Database Management System]
in the design phase.
Data Dictionary for Charlie’s
Baker Shop
Entity Attribute Description
Orders Order No Unique Identifier. Numbers in the range 1-
99999 required
Acc.No Unique Identifier. Numbers in the range 1-
99999 required
Date Short Form dd/mm/yy

Total Cost Cost of total order; Value up to £9999.99


required.
Customers Acc.No Unique Identifier. See Orders entity

Customer Company Name required; text only

Address All address details for customer incl postcode


required. Text & Numbers
Price List Item Unique Identifier. Numbers in the range 1-
9999required
Item Price Cost of item; Value up to £99.99 required

Part Order Order No Unique Identifier. See Orders entity

Item Unique Identifier. See Item entity

Quantity Numbers in the range 1-999 required


Database Systems

Analysis

• Requirements Definition
• Normalisation
• Entity-Relationship Diagrams
• Data Dictionaries
• Functions
Functions
A function is anything that acts on the
data in a database system and is classified
as input, process or output.
• Input
An input is a function that places new data in the
system such as creating, updating or deleting data

• Process
An automated function within the database system
e.g. automatic update of an attribute, checking the
particular value of an attribute, changing or
calculating new values from the data
Functions
• Output
A function that produces data from the
database system e.g. a report, letter or
summary of the data

Beyond these Operational functions modern


computerised database systems can provide a wide
range of Strategic and Tactical information which
can assist with planning and organising e.g. queries
and ordered lists can provide the Company with
invaluable marketing information
Listed Functions that affect each entity of
the Charlie’s Baker Shop database
Entity Input Process Output
Orders Add a new order. List all orders
Update an order.
Customers Add a new customer List all customers
Update a customers with outstanding
details orders
Delete a customers
details
Price List Add a new item List items and
Delete an item corresponding
prices
Part Add quantity of an Automatically List all orders
item ordered update total cost containing a
Order Amend the quantity of of an order particular item
an item ordered List all customers
ordering a
particular item
Database Systems -

Design database structures


to represent the data
model

THE DESIGN PHASE


Database Systems-Design Phase

 Database Structure and item names


relate to the data model
 Unique keys are chosen for all
Database structures
 Validity checks represent the data
model
 Data item characteristics represent the
data model
 Designed structures are appropriate to the
intended implementation method
Database Systems-Design Phase

 Database Structure and item names


relate to the data model
 Unique keys are chosen for all
Database structures
 Validity checks represent the data
model
 Data item characteristics represent the
data model
 Designed structures are appropriate to the
intended implementation method
 The conceptual design [Data Model or E- R
Diagram] has already been created in
the analysis phase using Entities, Relationships
and Attributes

The entities now become tables and the


relationships between these entities are
preserved between the tables

Most RDBMS have syntactical rules that


govern how fields and tables are named. This
may affect how we construct the field and
table names.
Database Systems-Design Phase
 Database Structure and item names
relate to the data model
 Unique keys are chosen for all
Database structures
 Validity checks represent the data
model
 Data item characteristics represent the
data model
 Designed structures are appropriate to the
intended implementation method
 Indexes
The keys chosen for the database structures are
the same as those identified in the data model.
These remember were established during the
normalisation process

Some RDBMS include tools that create


indexes of fields to speed up searches within
the database.
However, only Primary and Foreign keys
should normally be indexed to help speed up
this process.
Database Systems-Design Phase
 Database Structure and item names
relate to the data model
 Unique keys are chosen for all
Database structures
 Validity checks represent the data
model
 Data item characteristics represent the
data model
 Designed structures are appropriate to the
intended implementation method
Data entered into the database should be valid
and correct. Most RDBMS contain tools which
will offer 3 types of validity check

PRESENCE
Checks to see if a value is present or not. E.g. if a field
value must be set, a presence check would be carried out
on it.

RANGE
Checks to see if a value entered is within a prescribed
range.

RESTRICTED CHOICE
This would ensure that the user only entered data that
corresponded to a list of pre-set values e.g. N S E or W
Database Systems-Design Phase
 Database Structure and item names
relate to the data model
 Unique keys are chosen for all
Database structures
 Validity checks represent the data
model
 Data item characteristics represent the
data model
 Designed structures are appropriate to the
intended implementation method
Every RDBMS has its own set of data
types that it can implement.

In the design phase we create a more detailed


data dictionary that identifies the field types,
sizes, keys and validity checks that can be
implemented in the RDBMS
Database : Charlie’s Baker Shop
Table : Orders
Fieldname Type Size Validation Format Req'd Index
Order No Autonumber Size Yes Yes (Unique)
Primary Key
Acc. No Number Auto Yes No
Customer Text 35 Yes No
Address1 Text 50 Yes No
Address2 Text 50 No No
Address3 Text 50 Yes No
Postcode Text 8 XX9?_9XX Yes No
Date Date/Time Auto Short Date Yes No
Total Cost Currency Auto >=£10.00 £99.99 Yes No

Also refers to tables


that foreign keys
have come from
Database Systems-Design Phase
 Database Structure and item names
relate to the data model
 Unique keys are chosen for all
Database structures
 Validity checks represent the data
model
 Data item characteristics represent
the data model
 Designed structures are appropriate to
the intended implementation method
 Relationships

State the relationships that will be


implemented using the RDBMS. These
should be the same as for the E-R
diagram.

However, in the design phase we show the


relationships between the primary and
foreign key fields in each table.
Charlie’s Baker Shop
Customers (Acc. No. Orders (Order No.
Customer *Acc. No.
Address) Date
Total Cost)

Part Order (*Order No.


Price List (Item *Item
Item Price) Quantity)

[Customers.Acc.No.] 1: M [Orders.Acc.No.]

[Orders.Order No] 1: M [Part Order.Order No]

[Price List.Item] 1: M [Part Order.Item]


When you are designing the database
structures for your implementation you
must always consider what your RDBMS is
capable of doing.

There is no point designing a system that


cannot be implemented with the software
that you have available.
Database Systems -

Implement a designed database


structure based on an existing
system

THE IMPLEMENTATION PHASE


Database Systems
Implementation Phase
 Correctly implement database structures from
design
 Perform data manipulations effectively
 Carry out queries to meet given criteria efficiently
 Produce reports to meet given specifications
 Evaluate the database structure against the
existing system
 Ensure data is well managed and secure
Database Systems
Implementation Phase
 Correctly implement database structures from
design
 Perform data manipulations effectively
 Carry out queries to meet given criteria efficiently
 Produce reports to meet given specifications
 Evaluate the database structure against the
existing system
 Ensure data is well managed and secure
Using the chosen RDBMS each of the tables within
your design including all the relevant fields will be
specified and established.

Implement all the features of your detailed data


dictionary i.e.

 Table names
 Fieldnames and whether indexed or not
 Validity checks
 Primary/foreign keys

Once and only once the structure has been


established, is it possible to enter data into the tables
Database Systems
Implementation Phase
 Correctly implement database structures from
design
 Perform data manipulations effectively
 Carry out queries to meet given criteria efficiently
 Produce reports to meet given specifications
 Evaluate the database structure against the
existing system
 Ensure data is well managed and secure
 EDIT
An edit manipulation involves the user changing data
already present in the database
 
 SORT
A sort manipulation takes a range of data from the
database and sorts it on the values in one or more fields
 
 INSERT
An insert manipulation involves the user adding new
data to tables within the database
 
 DELETE
A delete manipulation involves the user removing data
from tables within the database
Database Systems
Implementation Phase
 Correctly implement database structures from
design
 Perform data manipulations effectively
 Carry out queries to meet given criteria efficiently
 Produce reports to meet given specifications
 Evaluate the database structure against the
existing system
 Ensure data is well managed and secure
 Queries are questions you can ask of the data in tables
within the database. They are similar to searches you
would perform within a flat-file database
 Queries create subsets of the data within the database by
field, record or both
 A query performed on a relational database will always
produce a table
 A query can be performed on more than one table because
the relationships between primary and foreign keys link
the tables together
 Queries not only produce subsets of the data, but can be
used to perform mathematical operations on this data

Base Tables – The original table that the query acted upon

Answer Tables – The table created by the query. This contains a


subset of the data from the base table/s
Styles of Query

 Textual
Queries that act on fields of the text data type
 
 Numeric
Queries that act on fields of the numeric data type
 
 Exact
Finds a specific match on a field for particular criteria
e.g. customers with surname ‘Smith’.
 
 Inexact
Looks for values within a range in a particular field
e.g. customers with names beginning with 'S'
 
 Combinations of search criteria
Uses a combination of criteria e.g. All customers who
ordered items costing <£1.50
Different tools have been developed to allow us to query
a relational database through the RDBMS
 
 Graphical Tools
Allow us to select and enter the details for the query graphically
e.g. The tool you are using in Microsoft Access
 
 Structured Query Language [SQL]
A recognised international standard for creating queries for relational
databases e.g. 
SELECT DISTINCT [Orders].[Acc.No.],
Sum([Orders].[Total Cost]) AS [SumOfTotal Cost]
FROM [Orders]
GROUP BY [Orders].[Acc.No.];

Often, an RDBMS will use both types of tool.


 Inexperienced users would use the graphical tool
 Experienced users would use SQL
Database Systems
Implementation Phase
 Correctly implement database structures from
design
 Perform data manipulations effectively
 Carry out queries to meet given criteria efficiently
 Produce reports to meet given specifications
 Evaluate the database structure against the
existing system
 Ensure data is well managed and secure
Reports

A report is like a query in that it can summarise


the data in the database. However reports are
used to produce printed output [ Hard Copy]
e.g. The user may require a listing of all
customers and their addresses from the database

N.B. When producing reports using MS Access


it is possible to perform some basic statistical
analysis on the data if the data type is numeric
Database Systems
Implementation Phase
 Correctly implement database structures from
design
 Perform data manipulations effectively
 Carry out queries to meet given criteria efficiently
 Produce reports to meet given specifications
 Evaluate the database structure against the
existing system
 Ensure data is well managed and secure
When the relational database has been produced an evaluation
should be performed against the existing system to identify any
improvements and a report compiled to include the following:

 Information summary of how the existing system is used


outlining restrictions of this system and limited usage

 Improvements in the efficiency and effectiveness of the new


system e.g. Reduction in entry and storage of duplicate data

 Automation of operations such as producing reports


 Saving in man hours for entering data and reduction in data
entry errors

 New facilities available through the new system such as


reports that analyse the data statistically or queries that automate
the production of summary data
Database Systems
Implementation Phase
 Correctly implement database structures from
design
 Perform data manipulations effectively
 Carry out queries to meet given criteria efficiently
 Produce reports to meet given specifications
 Evaluate the database structure against the
existing system
 Ensure data is well managed and secure
Legislation – Your legal responsibilities
 
 Data Protection Act (1998)
 
Ensures that people who keep information on computer (Data Users) give
rights to individuals (Data Subjects) who have information recorded about
them on computer
 
 Copyright, Design & Patents Act (1988)
 
Most published material is protected by this act i.e. there are restrictions
to the use you can make of such material in respect of copying selling and
adapting it.
 
 Computer Misuse Act (1990)
 
This act provides regulations that govern the access to and use of
computer systems and the information within them e.g. unauthorised use of
another person's username and password.

You might also like