chapter 12.3+ information systems database management

33
Chapter 12.3+ Information Systems Database Management

Upload: jaeden-dolan

Post on 31-Mar-2015

221 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Chapter 12.3+ Information Systems Database Management

Chapter 12.3+

Information SystemsDatabase Management

Page 2: Chapter 12.3+ Information Systems Database Management

2

Database Management SystemsDatabase: A structured set of data.Database Management System: (DBMS) A

combination of software and data, including:

Physical database: a collection of files that contain the data.

Database engine: software that supports access to and modification of the database contents.

Database schema: a specification of the logical structure of the data stored in the database.

Page 3: Chapter 12.3+ Information Systems Database Management

3

Database Management SystemsSpecialized database languages allow the user

to: specify the structure of data; add, modify, and delete data; query the database to retrieve specific stored

data.

Page 4: Chapter 12.3+ Information Systems Database Management

4

Database Management Systems

Figure 12.6 The elements of a database management system

Page 5: Chapter 12.3+ Information Systems Database Management

5

Databases

Databases are a recent development in the management of large amounts of data.

As paper file systems were “computerized” each application was implemented separately with its own data set.

These systems were riddled with both corrupt data and redundant data, none of which could be shared.

Page 6: Chapter 12.3+ Information Systems Database Management

6

Databases

The integration of separate systems into one database resolved these issues, but introduced new ones.

With all data shared, control of access to the data becomes a major concern.

Payroll doesn’t need to see your grades.

Page 7: Chapter 12.3+ Information Systems Database Management

7

Database Management SystemsA schema is a description of the entire

database structure used by the database software to maintain the database.

A subschema is a description of only that part of the database that is particular to a user’s needs.

Page 8: Chapter 12.3+ Information Systems Database Management

8

Database Management Systems A layered approach hides the complexities of

database implementation. User sees data in terms of the application. The application “sees” data in terms of the

database model. The DBMS “sees” data as it is organized.

Page 9: Chapter 12.3+ Information Systems Database Management

9

Database Management Systems Advantages of the layered approach include:

Simplification of the design process. Better control of access. Data Independence. Applications can be written in terms of simple,

conceptual views of the data – the database model.

Page 10: Chapter 12.3+ Information Systems Database Management

10

Database Models

A database model is a conceptual view of how to organize and manipulate data.

The most popular one is the Relational Model.

Page 11: Chapter 12.3+ Information Systems Database Management

11

The Relational Model

In a relational DBMS, the data items - and the relationships among them - are organized into rectangular tables.

As with spreadsheets, these tables consist of rows and columns. Each table is called a relation. The rows are called tuples. The columns are called attributes.

Page 12: Chapter 12.3+ Information Systems Database Management

12

The Relational Model

Of course, different authors adopt different terms. There is a commonly used, alternate set of names: Relations are also called tables.

A tuple can be referred to as a record,

and in this terminology a record is a collection of related fields.

Page 13: Chapter 12.3+ Information Systems Database Management

13

A Database Table

Figure 12.7 Part of a database table, made up of records and fields

Page 14: Chapter 12.3+ Information Systems Database Management

14

A Database Table

We can express the schema for this database table as follows:

Movie (MovieId:key, Title, Genre, Rating)

Page 15: Chapter 12.3+ Information Systems Database Management

15

Another Database Table

A partial CUSTOMER table.

Page 16: Chapter 12.3+ Information Systems Database Management

16

Another Database Table

We can express the schema for this table as:

Customer (CustomerId:key, Name, Address, CreditCardNumber)

Page 17: Chapter 12.3+ Information Systems Database Management

17

Relationships

A table can represent a collection of relationships between objects. The RENTS table relates Customers to the Movies they’ve rented by their respective Ids.

Page 18: Chapter 12.3+ Information Systems Database Management

18

Relationships

We can also express the schema for a relationship:

Rents (CustomerId, MovieId, DateRented, DateDue)

Note the absence of a key field.

Page 19: Chapter 12.3+ Information Systems Database Management

19

Relational Operations

There are 3 fundamental operations that can be used to manipulate the tables in a database: SELECT

Extracts rows (tuples) from a table (relation)

PROJECT Extracts columns (attributes) from a table (relation)

JOIN Combines 2 tables (relations) into 1

Page 20: Chapter 12.3+ Information Systems Database Management

20

Relational Operations

The result of any relational operation is a new relation. We can express these operations with a simple syntax.

NEW ← SELECT from MOVIE where RATING = “PG”

This operation creates a new relation (named NEW) by extracting all rows from the MOVIE table that have a RATING of PG.

Page 21: Chapter 12.3+ Information Systems Database Management

21

SELECT

The NEW relation.

MovieId Title Genre Rating

102 Back to the Future Comedy adventure PG

104 Field of Dreams Fantasy drama PG

Page 22: Chapter 12.3+ Information Systems Database Management

22

Relational Operations

The same syntax can be used for the other operations.

PGmovies ← PROJECT MovieId, Title from NEW

This operation creates a new relation (named PGmovies) that extracts 2 attributes from the NEW relation.

Page 23: Chapter 12.3+ Information Systems Database Management

23

PROJECT

The PGmovies relation.

MovieId Title

102 Back to the Future

104 Field of Dreams

Page 24: Chapter 12.3+ Information Systems Database Management

24

Relational Operations

A JOIN creates a new relation by combining 2 relations according to some criterion.

TEMP1 ← JOIN CUSTOMER and RENTS where CUSTOMER.CustomerId = RENTS.CustomerId

Page 25: Chapter 12.3+ Information Systems Database Management

25

JOIN

CustomerId Name Address CreditCardNumber CustomerId MovieId DateRented DateDue

Page 26: Chapter 12.3+ Information Systems Database Management

26

Relational Operations

The PROJECT operation can be used to remove the attributes we don’t want…

RENTALS ← PROJECT Name, Address, MovieId from TEMP1

Page 27: Chapter 12.3+ Information Systems Database Management

27

Relational Operations

The RENTALS relation.

Name Address MovieId

Page 28: Chapter 12.3+ Information Systems Database Management

28

Relational OperationsNow, JOINing RENTALS to PGmovies…

PGrenters ← JOIN RENTALS and PGmovies where RENTALS.MovieId = PGmovies.MovieId

…creates a table of customers who have rented PG movies.

Name Address MovieId MovieId Title

Page 29: Chapter 12.3+ Information Systems Database Management

29

Structured Query Language

Structured Query Language (SQL)

A comprehensive database language for managing relational databases.

Page 30: Chapter 12.3+ Information Systems Database Management

30

Queries in SQL

select attribute-list from table-list where condition

select Title from MOVIE where Rating = 'PG'

select Name, Address from CUSTOMER

select * from MOVIE where Genre like '%action%'

select * from MOVIE where Rating = 'R' order by Title

Page 31: Chapter 12.3+ Information Systems Database Management

31

Modifying Database Content

insert into CUSTOMER values (9876, 'John Smith', '602 Greenbriar Court', '2938 3212 3402 0299')

update MOVIE set Genre = 'thriller drama' where title = 'Unbreakable‘

delete from MOVIE where Rating = 'R'

Page 32: Chapter 12.3+ Information Systems Database Management

32

Database Design

Entity-relationship (ER) modeling A popular technique for designing relational

databases.

ER Diagram Chief tool used for ER modeling. Captures the important record types, attributes,

and relationships in a graphical form.

Page 33: Chapter 12.3+ Information Systems Database Management

33

Database Design These designations show the cardinality

constraint of the relationship

Figure 12.10 An ER diagram for the movie rental database