Database Management

6 downloads 184623 Views 206KB Size Report
Database. Management. Peter Wood. Introduction. Lecture plan. Database Management. Peter Wood ... long periods of time. (A DBMS is also referred to more simply as a database system.) .... Database Systems: A Practical Approach to. Design, Implementation, and Management. ... Systems. Prentice Hall, third edition, 2008.
Database Management Peter Wood Introduction

Database Management

Peter Wood Email: [email protected] Web: http://www.dcs.bbk.ac.uk/~ptw/

Lecture plan

Why study database management?

Database Management Peter Wood Introduction Lecture plan

1. The database market is huge 2. There’s a big demand for database skills 3. Managing data is a fundamental need for most applications 4. The subject is interesting and challenging

Databases are used everywhere

Database Management Peter Wood Introduction Lecture plan

I

Essential for large amounts of data: I I

banking, shopping, . . . (of course) scientific investigations, e.g. astronomical data, human genome

Databases are used everywhere

Database Management Peter Wood Introduction Lecture plan

I

Essential for large amounts of data: I I

I

banking, shopping, . . . (of course) scientific investigations, e.g. astronomical data, human genome

but also used in smaller-scale applications: I

I

iPhoto on Apple Macs uses sqlite3 to manage the photo library Squeezebox server uses mySQL to manage the music library

What is a Database?

Database Management Peter Wood Introduction Lecture plan

I

A database is a collection of persistent data

I

A database models part of the real world

I

A database is, in general, a shared resource

What is a DBMS?

Database Management Peter Wood Introduction Lecture plan

A DBMS is specialised software which is responsible for efficient storage and retrieval of large amounts of data in a database, allowing it to persist over long periods of time. (A DBMS is also referred to more simply as a database system.)

Database Management

Very simple database example name Horse and Hound Hound and Hare Pubs: March Hare Black Horse White Horse pub Horse and Hound Horse and Hound Hound and Hare Hound and Hare Sells: March Hare March Hare Black Horse Black Horse Black Horse White Horse

location Bloomsbury Islington Bloomsbury Islington Bloomsbury beer Bad Habit Rampant Ram Shining Wit Rampant Ram Bad Habit Rampant Ram Bad Habit Shining Wit Rampant Ram Rampant Ram

Peter Wood Introduction Lecture plan

price 1.50 2.00 2.75 2.50 1.75 2.50 2.50 2.25 2.50 2.75

Why Do We Need a DBMS?

Database Management Peter Wood

A DBMS is a software package that handles all the interaction of applications with the database. 1. It saves programmer time by providing a declarative query language, e.g. SQL. 2. It saves programmer time by automatically checking constraints. 3. It saves maintenance time by ensuring data independence. 4. It provides concurrent access to the database for multiple, simultaneous users. 5. It provides automatic recovery from failure. 6. It provides security to ensure appropriate access to data.

Introduction Lecture plan

Database Management

Three levels of Abstraction

Peter Wood

A DBMS hides details from the user/programmer using three levels of abstraction: view 1

view 2

···

logical level physical level

I

physical: how data is stored.

I

logical: based on a data model.

I

view: what programs or user see.

view n

Introduction Lecture plan

Data Independence

Database Management Peter Wood Introduction Lecture plan

Changes at one level of abstraction should not require changes at higher levels. I

physical data independence - the physical level may be changed without affecting the logical level.

I

growth independence - the independence of the view level from the addition of new structures to the database. ? Deletions of structures at the logical level disrupt views that reference them.

Instances and Schemas

Database Management Peter Wood Introduction

I

Databases change over time as information is inserted and deleted.

I

The collection of data stored in a database at any moment in time is called an instance of the database.

I

The overall design of the database is called the database schema.

I

Schemas change infrequently.

I

Physical schemas describe databases at the physical level.

I

Logical schemas describe databases at the logical level.

I

Schemas at the view level are sometimes called subschemas.

Lecture plan

Disadvantages of using a DBMS

Database Management Peter Wood Introduction Lecture plan

I

Cost

I

Lock-in

I

Complexity

Types of DBMS users

Database Management Peter Wood Introduction Lecture plan

I

End users.

I

Application programmers.

I

Database administrator (DBA).

I

Enterprise administrator - responsible for database design.

I

Application administrator - responsible for view design.

DBMS examples

Database Management Peter Wood Introduction Lecture plan

I

DB2

I

Oracle

I

mySQL

I

Access

I

SQLserver

I

various “NoSQL” systems, such as Cassandra, CouchDB, MongoDB

Data Model

Database Management Peter Wood Introduction Lecture plan

A data model consists of three components: 1. Structural part. 2. Integrity part. 3. Manipulative part - declarative or procedural.

The Relational Data Model

Database Management Peter Wood Introduction Lecture plan

1. Structural part - relations. 2. Integrity part - keys (entity integrity) and foreign keys (referential integrity). 3. Manipulative part - Structured Query Language (SQL) or the relational algebra.

Other Data Models

Database Management Peter Wood Introduction Lecture plan

I

entity-relationship model (next)

I

hierarchical data model - from 1960s and 1970s

I

network (CODASYL) data model - from 1960s and 1970s

I

object-oriented data model - from 1980s and 1990s

I

semi-structured data model (e.g. XML) - from 1990s

I

document or key-value models (for NoSQL systems) - from 2000s

Summary I I

I

I

I I

Databases are crucial to most organisations. A DBMS is a sophisticated piece of software that provides the interface between database users and the database itself. A DBMS has three levels of abstraction: physical, logical and view. Data independence means that changing data representation at a lower level does not affect a higher level. A data model has structural, integrity and manipulative parts. It is important to understand how 1. to access and update information in a database, e.g. using SQL 2. to design a database based on real-world constraints 3. a DBMS solves the problems associated with concurrent access and failure

Database Management Peter Wood Introduction Lecture plan

Lecture Plan

Database Management Peter Wood Introduction

1. Introduction to Databases 2. Data Modelling with the Entity-Relationship Model 3. The Basic Relational Model 3.1 Tables, Attributes and Domains 3.2 Primary and Foreign Keys Entity and Referential Integrity

4. Querying a Relational Database 4.1 4.2 4.3 4.4 4.5 4.6

Querying a Single Table Querying Multiple Tables Aggregating and Grouping Data Updating Data Null Values Transaction Management

Lecture plan

Lecture Plan - Continued

Database Management Peter Wood Introduction Lecture plan

5. Designing a Relational Database 5.1 The three levels of a Database System and Data Independence 5.2 The Normalization Problem 5.3 Boyce-Codd Normal Form 5.4 Third Normal Form

6. Databases and the Web There will be coursework !

Recommended books

Database Management Peter Wood Introduction Lecture plan

1. [UW08] − Covers most of the topics in this module, from a slightly theoretical or abstract perspective (> 500 pages) 2. [SKS11] − Comprehensive introduction to Database Management (> 1300 pages). 3. [CB10] − Another comprehensive and slightly less technical introduction to Database Management (> 1200 pages). Apart from the above books, there are many more good database books at all levels.

T. Connolly and C. Begg. Database Systems: A Practical Approach to Design, Implementation, and Management. Addison-Wesley, fifth edition, 2010. A. B. Silberschatz, H. F. Korth, and S. Sudarshan. Database System Concepts. McGraw-Hill, sixth edition, 2011. J. D. Ullman and J. Widom. A First Course in Database Systems. Prentice Hall, third edition, 2008.

Database Management Peter Wood Introduction Lecture plan