14. Databases. DATABASEMANAGEMENTSYSTEMDATABASEMANAGEMENTSYSTEM 14.1.

Post on 12-Jan-2016

228 views 0 download

transcript

14. Databases

DATABASEDATABASEMANAGEMENTMANAGEMENT

SYSTEMSYSTEM

DATABASEDATABASEMANAGEMENTMANAGEMENT

SYSTEMSYSTEM

14.114.1

DDBMS componentsBMS components

A database is a collection of data that is logically, but not necessarily physically, coherent.

A database management system (DBMS) defines, creates, and maintains a database and allows controlled access to users.

ARCHITECTUREARCHITECTUREARCHITECTUREARCHITECTURE14.214.2

DDatabase architectureatabase architecture

DDatabase architectureatabase architecture

DBMS users can be humans or application programs.

A DBMS has three levels: internal, conceptual, and external.

The internal level of a DBMS interacts directly with the hardware and is concerned with low-level access methods and byte transfer to and from the storage device.

The conceptual level of a DBMS defines the logical view of the data as well as the data model and schema diagrams.

The external level of a DBMS interacts directly with the user.

DATABASEDATABASEMODELSMODELS

DATABASEDATABASEMODELSMODELS

14.314.3

DDatabase modelsatabase models

A database model defines the logical design of data

The model also describes the relationships between different parts of data.

Three models:

Hierarchical model

Network model

Relational model

HHierarchical modelierarchical model

Data are organized as an upside down tree

Each entity has only one parent but can have several children.

NNetwork modeletwork model

The entities are organized in a graph, where some entities can be accessed through several path.

RELATIONALRELATIONALMODELMODEL

RELATIONALRELATIONALMODELMODEL

14.414.4

RRelational modelelational modelData are organized in two-dimensional tables

called relations.

The relational database management system (RDBMS) is the only database model in wide use today. The hierarchical and network models are obsolete.

Each column in a relation is called an attribute. The number of attributes in a relation is its degree.

Each row in a relation is called a tuple. The number of rows in a relation is its cardinality.

RRelational modelelational model

RRelationelation

OPERATIONSOPERATIONSONON

RELATIONSRELATIONS

OPERATIONSOPERATIONSONON

RELATIONSRELATIONS

14.514.5

IInsert operationnsert operation

None operations can be performed on relations.

An operation that operates on one relation is a unary operator. Unary operators include the insert, delete, update, select, and project operations.

DDelete operationelete operation

UUpdate operationpdate operation

SSelect operationelect operation

PProject operationroject operation

JJoin operationoin operation

An operation that operates on two relation is a binary operator. binary operators include the join, union, intersection, and difference operations.

UUnion operationnion operation

IIntersection operationntersection operation

DDifference operationifference operation

STRUCTUREDSTRUCTUREDQUERYQUERY

LANGUAGELANGUAGE

STRUCTUREDSTRUCTUREDQUERYQUERY

LANGUAGELANGUAGE

14.614.6

SSQLQLThe Structured Query Language (SQL) is the

language standardized by ANSI and ISO for use on relational databases.

For example: Fig 14.10select * 整個 tuple都抓出來from COURSESwhere Unit = 5

SSQLQL- - cont’s

For example: select Course-Namefrom COURSESwhere Unit = 5