Week 1 Lecture 1 Introduction and Architecture Introduction and Architecture.… · – Undertake...

31
Database Technology Database Architecture and Structure

Transcript of Week 1 Lecture 1 Introduction and Architecture Introduction and Architecture.… · – Undertake...

Page 1: Week 1 Lecture 1 Introduction and Architecture Introduction and Architecture.… · – Undertake one assignment, ... – Architecture and usage of RDBMS. ... Week 1 Lecture 1 Introduction

Database Technology

Database Architecture and Structure

Page 2: Week 1 Lecture 1 Introduction and Architecture Introduction and Architecture.… · – Undertake one assignment, ... – Architecture and usage of RDBMS. ... Week 1 Lecture 1 Introduction

Lecture outline

• Course introduction• Desirable features• Other forms of data storage• Definition and use of databases• Architecture of a database• Database Management systems

Page 3: Week 1 Lecture 1 Introduction and Architecture Introduction and Architecture.… · – Undertake one assignment, ... – Architecture and usage of RDBMS. ... Week 1 Lecture 1 Introduction

Introduction to Database Technology course

DT228/3Semester 1

Page 4: Week 1 Lecture 1 Introduction and Architecture Introduction and Architecture.… · – Undertake one assignment, ... – Architecture and usage of RDBMS. ... Week 1 Lecture 1 Introduction

Breakdown of course• This course is valued at 5 ECTS points.• There are 36 contact hours, leaving 64 self-study hours.• Weekly contact hours:

– 1 hour lecture– 1 hour tutorial– 1 hour lab

• Self-Study expectations:– Finish all lab / tutorial exercises assigned to you.– Undertake one lab test– Undertake one assignment, as part of a group.– Learn the theoretical and practical content of the course.

Page 5: Week 1 Lecture 1 Introduction and Architecture Introduction and Architecture.… · – Undertake one assignment, ... – Architecture and usage of RDBMS. ... Week 1 Lecture 1 Introduction

Lectures

• Design– Designing a data model using Normalisation

• Practical– Standard SQL and Oracle PL/SQL to allow for

lab classes.• Theoretical

– Architecture and usage of RDBMS.– Theory of concurrent usage, architecture,

data protection, security, recovery.

Page 6: Week 1 Lecture 1 Introduction and Architecture Introduction and Architecture.… · – Undertake one assignment, ... – Architecture and usage of RDBMS. ... Week 1 Lecture 1 Introduction

Tutorials

• Practice of database schema design.• Problems relating to concurrency and

transaction design.• Design of a relational model (in a group)

for a system from a set description.• Design and specification of queries and

transactions that would be required by the users of the designed system.

Page 7: Week 1 Lecture 1 Introduction and Architecture Introduction and Architecture.… · – Undertake one assignment, ... – Architecture and usage of RDBMS. ... Week 1 Lecture 1 Introduction

Practicals• Introduction to Oracle SQL*Plus.• Implementation of standard query types on a

populated schema.• Creation and population of a schema as

designed in tutorials.• Implementation of task-based queries.• Implementation of task-based transactions,

using commit and roll-back, taking concurrency issues into account.

• Some time will be given to doing your lab test and assignment.

Page 8: Week 1 Lecture 1 Introduction and Architecture Introduction and Architecture.… · – Undertake one assignment, ... – Architecture and usage of RDBMS. ... Week 1 Lecture 1 Introduction

Assessment

• 30% practical:– 10% lab test.– 20% group system implementation.

• 70% examination (2 hours):– 4 questions, answer 3.

• Q1 compulsory, worth 40%, – based on tutorial and practical work.

• Q2, 3 and 4 worth 30% each.– Based on tutorial, practical and theory work.

Page 9: Week 1 Lecture 1 Introduction and Architecture Introduction and Architecture.… · – Undertake one assignment, ... – Architecture and usage of RDBMS. ... Week 1 Lecture 1 Introduction

You will learn

• Data modelling• Relational database theory• Use of Oracle Database 10g, using the

SQL*Plus and iSQL*Plus tools.• Design and implement:

– Queries in SQL– Transactions in SQL– Procedures, Functions, Packages and

Triggers in PL/SQL

Page 10: Week 1 Lecture 1 Introduction and Architecture Introduction and Architecture.… · – Undertake one assignment, ... – Architecture and usage of RDBMS. ... Week 1 Lecture 1 Introduction

Data modelling

• How to model data from the meaning of the stored data.

• Derive a data model from system data entries and outputs.

• Use Data Normalisation to improve your model.

Page 11: Week 1 Lecture 1 Introduction and Architecture Introduction and Architecture.… · – Undertake one assignment, ... – Architecture and usage of RDBMS. ... Week 1 Lecture 1 Introduction

Models you will see

• Sample schema– Builders’ provider’s stock control system – I

will use this to demonstrate techniques• YOUR GROUP schema

– YOU and two others from your class will design and build this.

Page 12: Week 1 Lecture 1 Introduction and Architecture Introduction and Architecture.… · – Undertake one assignment, ... – Architecture and usage of RDBMS. ... Week 1 Lecture 1 Introduction

Desirable features in an information system

• Integrity• Referential integrity• Data independence • Controlled redundancy• Security• Privacy

Page 13: Week 1 Lecture 1 Introduction and Architecture Introduction and Architecture.… · – Undertake one assignment, ... – Architecture and usage of RDBMS. ... Week 1 Lecture 1 Introduction

Integrity

• Valid and consistent stored data– Remove redundancy– Impose constraints WITH THE METADATA

• E.g. constraints: not null, unique, primary key• Check conditions.

Page 14: Week 1 Lecture 1 Introduction and Architecture Introduction and Architecture.… · – Undertake one assignment, ... – Architecture and usage of RDBMS. ... Week 1 Lecture 1 Introduction

Referential integrity

• Data only valid in relation to another occurrence.– Master : detail relationship

• E.g. Can’t add a stock item without a supplier– Implemented through Foreign Keys and

triggers.

Page 15: Week 1 Lecture 1 Introduction and Architecture Introduction and Architecture.… · – Undertake one assignment, ... – Architecture and usage of RDBMS. ... Week 1 Lecture 1 Introduction

Data independence• This is where the data is independent of the

program that uses it:– E.g.

• Select stock_code from stock;– This will work, regardless of the definition of the table

stock, unless• You have no access to the table stock• There is no column ‘stock_code’ in the table stock

– This allows us to change • the front layers of software without changing the tables• The tables without changing the front layers (some

recompilation may be required)

Page 16: Week 1 Lecture 1 Introduction and Architecture Introduction and Architecture.… · – Undertake one assignment, ... – Architecture and usage of RDBMS. ... Week 1 Lecture 1 Introduction

Controlled redundancy

• Controlled redundancy– Redundant data causes problems

• E.g. staff details – addresses and phone numbers,• If recorded separately for payroll and human

resources, then when one is changed, the other is not.

• Bank accounts and credit card accounts.– NO redundancy causes problems

• One server goes down, there is no other server• In order to retrieve information, a traversal of three

tables is required – inefficient.

Page 17: Week 1 Lecture 1 Introduction and Architecture Introduction and Architecture.… · – Undertake one assignment, ... – Architecture and usage of RDBMS. ... Week 1 Lecture 1 Introduction

Security• From theft and fraud• Loss of confidentiality• DBMS controls:

– Granting of different privileges to different users• You will have SELECT access to the tables in the BUILDER

schema.• You have owner access to your own Schema and to your team

schema.• You may grant and revoke access to your tables to others in your

class.– Backup and Recovery– Journalling– Commit and Rollback– Encryption

Page 18: Week 1 Lecture 1 Introduction and Architecture Introduction and Architecture.… · – Undertake one assignment, ... – Architecture and usage of RDBMS. ... Week 1 Lecture 1 Introduction

Privacy

• Can be maintained through:– Use of views

• E.g. although the staff table shows full details of– Salary– Direct payments to family members– Loan repayments, etc.

• The person in charge of the staff roster only sees:• Name, rank, qualifications, free slots (probably a

different table)

Page 19: Week 1 Lecture 1 Introduction and Architecture Introduction and Architecture.… · – Undertake one assignment, ... – Architecture and usage of RDBMS. ... Week 1 Lecture 1 Introduction

File systems• Predecessors of Database Systems• File types:

– Sequential or serial• Suitable for use on a serial medium – e.g. a tape.• Access is determined by the ‘position’ of the reader on the

serial file or tape. No sharing.– Indexed sequential

• Closest in form to relational databases• Can be used to implement relational databases, but all of the

DBMS features must be programmed in.– Relative

• Based on the offset of the record from the start of the file.• Field values are not involved in keys.

Page 20: Week 1 Lecture 1 Introduction and Architecture Introduction and Architecture.… · – Undertake one assignment, ... – Architecture and usage of RDBMS. ... Week 1 Lecture 1 Introduction

Database definition• a computerised record-keeping system• used by a range of users who have different

requirements– minimal enquiries– in-depth updating– restructuring

• A well-implemented database will have data integrity, data independence, controlled redundancy, security and privacy, for all users.

Page 21: Week 1 Lecture 1 Introduction and Architecture Introduction and Architecture.… · – Undertake one assignment, ... – Architecture and usage of RDBMS. ... Week 1 Lecture 1 Introduction

Uses of a Database

• Generally used for on-line transaction processing (OLTP)

• Data Warehouses are a hybrid of databases which are used for On-line analytical processing (OLAP)

Page 22: Week 1 Lecture 1 Introduction and Architecture Introduction and Architecture.… · – Undertake one assignment, ... – Architecture and usage of RDBMS. ... Week 1 Lecture 1 Introduction

Structure of a databaseExternalSchema

ConceptualSchema

InternalSchema

PhysicalSchema

Page 23: Week 1 Lecture 1 Introduction and Architecture Introduction and Architecture.… · – Undertake one assignment, ... – Architecture and usage of RDBMS. ... Week 1 Lecture 1 Introduction

External level

• Level visible to user• Multiple views of the system

– e.g. View an order - see limited product and customer information

• Only the database Administrator may access the whole database at this level

Page 24: Week 1 Lecture 1 Introduction and Architecture Introduction and Architecture.… · – Undertake one assignment, ... – Architecture and usage of RDBMS. ... Week 1 Lecture 1 Introduction

EXTERNAL SCHEMA

• Each external view is defined by means of an external schema

• Provides definitions of each external view.• Written in a Data Definition Language• individual to the user • accessed through a 3GL, a query language or a

special purpose forms or menu-based language

Page 25: Week 1 Lecture 1 Introduction and Architecture Introduction and Architecture.… · – Undertake one assignment, ... – Architecture and usage of RDBMS. ... Week 1 Lecture 1 Introduction

Conceptual level

• CONCEPTUAL - represents the entire information content of the database

• Consists of multiple types of conceptual record. This level preserves the data independence of the database.

• CONCEPTUAL SCHEMA - defines each of the various types of conceptual record, in a conceptual Data Definition Language.

Page 26: Week 1 Lecture 1 Introduction and Architecture Introduction and Architecture.… · – Undertake one assignment, ... – Architecture and usage of RDBMS. ... Week 1 Lecture 1 Introduction

Internal level

• INTERNAL - a low-level representation of the entire database; it consists of multiple occurrences of multiple types of internal record. It is the stored record, inasmuch as it contains all but the device-specific information on the storage of the database.

• PHYSICAL - the physical device and block addresses for each of the records.

Page 27: Week 1 Lecture 1 Introduction and Architecture Introduction and Architecture.… · – Undertake one assignment, ... – Architecture and usage of RDBMS. ... Week 1 Lecture 1 Introduction

Mappings

• Each level maps onto adjoining levels• conceptual / internal mapping specifies how

conceptual records and fields are represented at the internal level

• Changes can be made in the internal level without affecting the conceptual level

• external / conceptual mapping defines the correspondence between an external view and the conceptual view

Page 28: Week 1 Lecture 1 Introduction and Architecture Introduction and Architecture.… · – Undertake one assignment, ... – Architecture and usage of RDBMS. ... Week 1 Lecture 1 Introduction

DBMS - Database Management System

• software handling access to the database• allows both the database administrator

and all users the access to the database to which they are entitled

Page 29: Week 1 Lecture 1 Introduction and Architecture Introduction and Architecture.… · – Undertake one assignment, ... – Architecture and usage of RDBMS. ... Week 1 Lecture 1 Introduction

How requests are processed

• User issues request (e.g. through SQL)• DBMS intercepts and analyses request• DBMS inspects user's external schema, external

to conceptual mapping, conceptual schema, conceptual to internal mapping and the storage structure definition.

• DBMS executes operations on stored database.

Page 30: Week 1 Lecture 1 Introduction and Architecture Introduction and Architecture.… · – Undertake one assignment, ... – Architecture and usage of RDBMS. ... Week 1 Lecture 1 Introduction

DATABASE ADMINISTRATOR (DBA)

• Decide on the storage structure and access strategy

• Liaise with the users• Define security and integrity checks• Define a backup and recovery strategy• Monitor and respond to performance

Page 31: Week 1 Lecture 1 Introduction and Architecture Introduction and Architecture.… · – Undertake one assignment, ... – Architecture and usage of RDBMS. ... Week 1 Lecture 1 Introduction

Utilities used by the DBA

• Load routines• Dump/Restore routines• Reorganisation routines• Statistics routines• Analysis routines• Data dictionary (containing METADATA,

which gives data descriptions and mappings)