30
Database Systems Marcus Kaiser School of Computing Science Newcastle University

Database Systems

Embed Size (px)

DESCRIPTION

Database Systems. Marcus Kaiser School of Computing Science Newcastle University. Aims. provide an understanding of the role of Databases provide an understanding of the functionality of Databases introduce the skills of Database design. Student Objectives. - PowerPoint PPT Presentation

Citation preview

Page 1: Database Systems

Database Systems

Marcus KaiserSchool of Computing ScienceNewcastle University

Page 2: Database Systems

Aims

provide an understanding of the role of Databases provide an understanding of the functionality of

Databases introduce the skills of Database design

Page 3: Database Systems

Student Objectives

an awareness and understanding of the potential problems of storing data outside a Database system

a knowledge and understanding of what a database system can do

an awareness of when it is appropriate to use a Database

an introduction to how Database systems store information and process queries

an introduction to the skills of designing databases

Page 4: Database Systems

Core Content Storing Data Outside a Database Management System

Methods Issues

Advantages of Database Management Systems Overview of Database Management Systems Introduction to Database Design How Databases Store Information How Databases Access Information Advanced Issues

Security

Page 5: Database Systems

Importance:

• Database Systems are the main technology used to manage business information• Databases are used extensively in Bioinformatics• Computer scientists use Databases in most projects

Page 6: Database Systems

By the end of this Theme you should be able to:

identify opportunities for the use of a Database in business/Bioinformatics/Computing

design Databases use a Database explain what Databases offer explain how Databases store and access data

Page 7: Database Systems

What is a Database ?

A collection of related Data about a subject that provides a base for procedures such as retrieving information and making decisions

Page 8: Database Systems

Why are they important

All organisations are highly dependent on the effective use of information day-to-day operations historic analysis prediction

Page 9: Database Systems

Storing Data outside a Database System

Storing Data in Files (similar problems with spreadsheets) Data often stored in as a delimited file (‘,’) e.g. a Companies Personnel Address Database held in a file

has one entry for each employee:Name , Initial ,Street, Town, Post Code, Telephone NumberSmith,A,73 Dover St., Newcastle, NE2 3SR,01912234554Jones,C.A.,25 Spring Rd., Sunderland, S12 7DD,01914566547

We could then write a program to access the file to pick out fields e.g. telnum Smith would print 01912234554 e.g. address Jones would print

25 Spring Rd., Sunderland, S12 7DD but this has limitations....

Page 10: Database Systems

Problems with this Approach : Data Redundancy

Data Redundancy If there is no central database then the same information may be held in

several different places e.g.

The personnel department has the address list shown above but, the payroll group needs some different information and keeps its

own records on each employeeName , Initial , Street, Town, Post Code, National Insurance Number, Salary

Smith,A,73 Dover St., Newcastle, NE2 3SR, WM12234, 15000Jones,C.A.,25 Spring Rd., Sunderland, S12 7DD,WM32345,21450

There is redundancy in the name and address information stored in multiple places wastes storage space updates take twice the work if they happen .....

Page 11: Database Systems

Problems: Data Integrity

When common data is kept in separate files discrepancies often develop e.g. Name and Address information

One may be updated but not the other

Page 12: Database Systems

Interdependence of Programs and Data Files

The program which accesses the data has to know the format of the data Change the format, and you have to change the access program

e.g. consider previous address databaseName , Initial, Street, Town, Post Code, National Insurance Number, Salary

Smith,A,73 Dover St., Newcastle, NE2 3SR, WM12234, 15000Jones,C.A.,25 Spring Rd., Sunderland, S12 7DD,WM32345,21450

a program has been written to generate address labels from this file but.. someone has complained about being addressed as A. Smith

rather than as Dr. A. Smith ... so a title field is added to the file:

Name , Initial, Title, Street, Town, Post Code, National Insurance Number, SalarySmith,A,Dr,73 Dover St., Newcastle, NE2 3SR, WM12234, 15000Jones,C.A.,Mrs,25 Spring Rd,Sunderland,S12 7DD,WM32345,21450

so now all programs which access this file have to change.

Page 13: Database Systems

Data Inconsistency when a Computer Fails

Consider the following Sequence of events: Sue @ Newcastle University ATM 11.00 Check Balance 11.01 ATM says there’s £200 11.02 Ask for £200 11.03 ATM Finds £200 in account 11.04 ATM Gives £200 11.05 ATM Stores £0 in Balance

What if the computer crashes at 11.04:30 ? the balance is wrong

Page 14: Database Systems

Data Loss when a Computer Fails

What if the Disk holding the data file breaks ? Do we just loose all that information?

Page 15: Database Systems

Simultaneous Access to the Data

Sue @ Newcastle University ATM 11.00 Check Balance 11.01 ATM says there’s £200 11.02 Ask for £200 11.03 ATM Finds £200 in account 11.04 ATM Gives £200 11.05 ATM Stores £0 in Balance

Jim @ Metro Centre ATM 11.00 Check Balance 11.01 ATM says there’s £200 11.02 Ask for £200 11.03 ATM Finds £200 in account 11.04 ATM Gives £200 11.05 ATM Stores £0 in Balance

• Sometimes problems can occur when a file is being updated if there is more than one user.

• e.g. Sue and Jim have a joint bank account.• they go shopping separately and both run out of money at the

same time• they both head for the nearest ATM.......

Page 16: Database Systems

Security

Some data needs to be protected only certain users are allowed to access it

e.g. Anyone in Personnel can see someone's address

(to send them a letter) Only the Head of Personnel can see their salary Only the Head of Personnel can change a salary

Page 17: Database Systems

Remote Access

Due to the problems of keeping multiple copies of data... ...many organisations wish to centralize information If the organisation is distributed so everyone can’t use the

same computer, how do they all get access to the data ?

Page 18: Database Systems

Remote Access to the data ?

?

? ?

Page 19: Database Systems

Requirements

Remove Redundancy – or at least control it Data Integrity Separation of data and program Prevent inconsistency when systems fail Allow multiple (simultaneous) interactions High level of security Remote access Access by humans and computers

Page 20: Database Systems

Database Management Systems: Structure

DBMSSoftware

Query Language

Database

ApplicationProgram

User QueryPre-Defined

Applications:Report GeneratorQuery by Forms

Page 21: Database Systems

Database Design

Page 22: Database Systems

Designing a Database

Before creating a Database we need to design it Database design cannot be done purely mechanically

but there are techniques which help The steps are:1. Decide on what subjects are covered by the database2. Decide how they are related to each other3. Decide on what characteristics they have4. Derive the database tables from the design5. Create the database tables using database software

Page 23: Database Systems

Decide what Subjects are Covered by the Database

Rules: Look at what the subject is about, rather than the

conclusions you want to find Think about the subject independently of any particular

database software (or computing at all) Don’t design database on computer

Focus on the data you are likely to collect, rather than how a computer will organise the data

Page 24: Database Systems

Decide on what subjects are covered by the DB

Subjects are called Entities: things that hold interest for you in your database represent a class of things precise definition different for every database you create

Page 25: Database Systems

Example: a Crime database The police want to track cases

When a robbery has happened who is involved? What was taken? Did this go to court? What was the verdict?

What are the Entities (subjects) here? Police Officer Stolen Item Case Result

Page 26: Database Systems

Example: a Crime database What are the entities?

Page 27: Database Systems

Decide how the entities are related to one another

Relationships a significant association between the entities represented as a diamond

Each relationship has: a name a degree (more on this later)

Names Pick a simple word that encapsulates the relationship Concentrate on the main entities first: the rest can

come later when you understand the problem better

Page 28: Database Systems

Naming relationships

Page 29: Database Systems

Deciding on the Attributes of the Entities

Attributes are details about the state of an entity They are things we want to know about an entity Ensure each has a unique name within the Entity They are usually drawn as spokes on Entity-Relationship diagrams:

Page 30: Database Systems

SummaryDatabase requirementsRemove Redundancy – or at least control itData IntegritySeparation of data and programPrevent inconsistency when systems failAllow multiple (simultaneous) interactionsHigh level of securityDatabase structure (Entity-Relationship model)EntityAttributeRelationship