0% found this document useful (0 votes)
23 views54 pages

Foundations 54

Uploaded by

Aigul Kaskina
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views54 pages

Foundations 54

Uploaded by

Aigul Kaskina
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 54

P00482 Database Technology

Analysis, design, implementation and operation of database systems.

• Database foundations
• Data modelling
• Properties of relational databases
• Normalisation
• Relational algebra and SQL
• Properties of OO databases
• Distributed DB, multi-DB, Web-DB

©P00482 - 2008 1
L&T infrastructure

• Oracle
• Educ software • Apache

Linux
• e-materials
• Assignment Store • Perl, CGI, DBI
• telnet, ftp, ed’s Unix • mySQL

•Web main server


•E-materials
•Software tutorials
• Windows/Linux/MacOS
•Documenation
• web tools, editors
• ppt, pdf,telnet, ftp, etc.

©P00482 - 2008 2
• web-site
• cs3% /help
• books

©P00482 - 2008 3
• web-site
• cs3% /help
• books

• Communication area for submission of the students’ work

• Exercises, solutions and explanation for programming problems

• Software compendia and explanatory notes

• Virtual tutorials

©P00482 - 2008 4
/help

VIRTUAL

PROBLEMS

• web-site
TUTORIALS
• cs3% /help
• books REVISION

assignment

SQLhelp

SQLsupplement

0-operating. ORACLE.SQL

1-data_definition.SQL

SQLprogramming 2-one_table_queries.SQL

3-joining_tables.SQL

4-transaction.SQL

5-insertion.SQL

6-deletion.SQL

7-Case_Study.SQL

8-menus-and-filenames.SQL
©P00482 - 2008 5
9-sequences.SQL
MAIN SUPPORTING SOFTWARE
ORACLE v.10 (SQL & PL/SQL)

EDUCATIONAL SOFTWARE
LEAP RDMS based on algebraic processor
SQL Tutor
UNIX help

UTILITIES
puTTy remote logging
ftp file transmition between servers
pdf writer to produce files in portable format

©P00482 - 2008 6
Stanczyk, Champion & Leyton
Theory & Practice of Relational Databases (2nd ed)
• web-site Taylor & Francis, 2001
• cs3% /help http://www.theorypractice.org
• books
Date CJ
An Introduction to Database Systems (8th ed)
Addison-Wesley 2004

O'Neil/O'Neil
Databases - Principles, Programming, Performance (2nd ed)
Morgan Kaufmann 2001

Elmasri/Navathe
Fundamentals of Database Systems (3rd ed.)
Addison Wesley 2000

Korth /Silberschatz
Database System Concepts (3rd ed)
McGraw Hill 2001

©P00482 - 2008 7
DATA DATA DATA
COLLECTION COLLECTION COLLECTION

OWN OWN OWN


DATA DATA DATA
FILES FILES FILES

OWN OWN OWN


PROCESSES PROCESSES PROCESSES
Pascal Java C

Application A Application B Application C


Project Personnel Financial
Control Info System Info System

©P00482 - 2008 8
• Redundancy of data

• Non-interchangeability of data

• Non-interchangeability of processes

• Non-transparency of the application software

• Inflexibility of the application software

• Uncontrolled expansion

©P00482 - 2008 9
DATA MANAGEMENT ROUTINES
all communication
database physical representation 
user/program
CENTRAL STORE OF DATA
+
DATA DESCRIPTION
solely through
the DataBase Management System
i.e.
every activity in the system, such as:
RETRIEVAL ROUTINES
• defining and modifying database
objects
• inserting, deleting and updating
• retrievals
is controlled by the DBMS
USERS & PROCESSES

©P00482 - 2008 10
DBMS
• Data Definition Language
to create and modify database objects

• Query Language
to support all forms of retrieval and updating

• Interfaces to
operating system
telecommunication system
programming languages
other utility software

• Data Dictionary
- a complete description of the database structure and conten

©P00482 - 2008 11
VIEW C

VIEW B

VIEW A

CONCEPTUAL  EXTERNAL
mapping
D
B
M
S CONCEPTUAL MODEL

CONCEPTUAL  INTERNAL
mapping

INTERNAL MODEL

ANSI/SPARC 3-level database architecture

©P00482 - 2008 12
Database models

• Inverted files
• Hierarchical
• Network (CODASYL)
• Relational
• Deductive (logical)
• Object Oriented
• Functional

©P00482 - 2008 13
Relational database model

very regular structures and processing  simple theoretical base


extensive utilisation in industrial and commercial application

• separation of physical & logical aspects

• data - process independence

• high level of data abstraction

• universal & uniform data structure

• global behavioural rules

• set of higher-level operations

• structure optimisation algorithm

©P00482 - 2008 14
Modelling the data

Real Informal Systematic Computable


Informal
World Conceptual Conceptual
Transformation Model Modelling Model

©P00482 - 2008 15
entity

anything that has reality and distinctness of being in fact or in thought


a physical or abstract object that can be distinguished from other objects

John Wilkes , 99079663 is an entity occurrence since the distinct


STUDENT
features (name, student-number) uniquely identify an existing person

BA 897 to New York is an entity occurrence since its distinct features


FLIGHT (flight#, destination) distinguish one particular flight from many others

entity type - a class of


entity occurrences characterized by the same attributes

©P00482 - 2008 16
Property - a named characteristic of an entity

Attributes
properties that represent an entity in the target system
(i.e. those whose values are to be stored in the database)

Domain
a set of all permitted values for each attribute

©P00482 - 2008 17
LECTURER
CREDIT
TITLE VALUE
type

No COURSE TERM

Dr Brown
Database 2 units
Design
occurrence

8049 DB-COURSE Term 3

©P00482 - 2008 18
No
TITLE
LECTURER COURSE entity-name
CREDIT
TERM

COURSE (No, TITLE, LECTURER, CREDIT, TERM)

attribute-names

©P00482 - 2008 19
super-entity
common attributes

UNIVERSITY_MEMBER
ID, Name, DoB, PermAddress

STUDENT
sub-entity TermAddress, Fields
differentiating
attributes
LECTURER
Qualifications, Salary

©P00482 - 2008 20
A relationship is a named directed mapping between two entity types

• one-to-one
an element from one class is mapped to
exactly one element in another class

• one-to-many
an element from one class is mapped to
one or more elements in another class

• many-to-many
zero, one or more elements from one class are mapped to
zero, one or more elements in another class, and vice-versa

©P00482 - 2008 21
physical entities abstract entities

St-No
NAME
HomeADDRESS DEPT#
STUDENT DEPARTMENT NAME
TermADDRESS
SEX HEAD-Id
DOB
Staff-Id
MOD#
NAME TITLE
ADDRESS MODULE
LECTURER LECTURER
QUAL CREDIT
SALARY TERM
DOB
St-No
BUILDING TITLE
OFFICE# OFFICE PROJECT SUPERVISOR
AREA GRADE
YEAR

St-No
association MOD#
entity RESULTS
DATE
GRADE

©P00482 - 2008 22
COMPILER
John

DATABASE
Eve

EXPERT SYSTEM
Mary
WORDPROCESSOR
Steve
SPREADSHEET

www-BROWSER Ann

PROJECT is-carried
STUDENT
-out-by

optional compulsory

©P00482 - 2008 23
John

Smith Eve

Brown
Mary

Green Steve

Ann

LECTURER counsels STUDENT

optional compulsory

©P00482 - 2008 24
Introduction to Calculus

Mathematical Logic
John
Set Theory & Topology

Eve Data Structures

Theory of Computation
Mary
Programming
Steve
Information Systems

Peter Software Engineering

Database Design

Artificial Intelligence

STUDENT enrols MODULE

©P00482 - 2008 25
compulsory optional
m:n decomposition

STUDENT MODULE

RESULTS

©P00482 - 2008 26
super/sub entity

UNIVERSITY
MEMBER
carries_out

STUDENT
SYSTEM PROJECT

LECTURER
has_account_on
supervises

©P00482 - 2008 27
EAR DIAGRAM
DEPARTMENT delivers

prerequisite_for

employs
MODULE

occupied
OFFICE LECTURER
by is_on

has
supervises TEACHING
counsels SCHEME

carried
PROJECT STUDENT
out_by

enjoys

RESULTS
©P00482 - 2008 28
TRANSACTION PROPAGATION - SIMPLIFIED SCHEME

delete lecturer X ::=


re-assign office to another lecturer
DEPARTMENT
re-assign project supervisor
for all projects supervised by X
MODULE

re-assign Personal Tutor


OFFICE LECTURER
for all students counselled by X

TEACHING
update teaching scheme ::=
SCHEME for all subjects taught by X
assign replacement lecturer;
PROJECT STUDENT if no suitable replacement

delete all modules affected ::=


RESULTS re-assign prerequisites
delete records of affected
modules

delete record of lecturer X

©P00482 - 2008 29
RELATIONAL MODEL PRINCIPLES

Clear distinction between the logical and physical aspects


of database management (including database design, data
retrieval and data manipulation) which resulted in so-called
data independence.

Structural simplicity, so that all users and programmers


(quite irrespective of their expertise in computing) have a
common understanding of the data, and can communicate
easily with one another about the data.

Set-oriented processing, that is the ability to express in a single


statement the processing of multiple sets of records at the time.

©P00482 - 2008 30
RELATIONAL MODEL as a FORMAL SYSTEM

STRUCTURE BEHAVIOUR

OPERATIONS

©P00482 - 2008 31
Sets

1  N
element  set
a  alphabet

membership test • DAYS = {Mon, Tue, Wed, Thu, Fri, Sat, Sun}
Mon  DAYS,
BoxingDay  DAYS

• oddN = {x: x  N and x = 2n + 1, n  N}


3  oddN
4  oddN

©P00482 - 2008 32
empty set
• contains no elements
{ }
• is a subset of every set

universal set • contains all sets


U

• no duplicates
{a, a, a, b, c, c}  {a, b, c}
global rules
• order of elements immaterial
{John, Mary, Anne}  {Anne, John, Mary}

©P00482 - 2008 33
Operations

inclusion B A
A  B  (x  A  x  B) forall x  A

union A B
A  B  (x: x  A or x  B)

difference A B
A \ B  (x: x  A and x  B)

A B
intersection A  B  (x: x  A and x  B)

©P00482 - 2008 34
cartesian product

A
B

A x B

A x B = { <a, b> : forall a, b a  A and b  B }

©P00482 - 2008 35
M
W
PETER 
PAUL   MARY

STEVE   EVE

JAMES   ANNE

GEORGE   JANE
KEITH   SUE

M x W =

{<PETER, MARY>, <PETER, EVE>, <PETER, ANNE>, <PETER, JANE>, <PETER, SUE>,
<PAUL, MARY>, <PAUL, EVE>, <PAUL, ANNE>, <PAUL, JANE>, <PAUL, SUE>,

<STEVE, MARY>, <STEVE, EVE>, <STEVE, ANNE>, <STEVE, JANE>, <STEVE, SUE>,

<JAMES, MARY>, <JAMES, EVE>, <JAMES, ANNE>, <JAMES, JANE>, <JAMES, SUE>,

<GEORGE, MARY>, <GEORGE, EVE>, <GEORGE, ANNE>, <GEORGE, JANE>, < GEORGE, SUE>,

<KEITH, MARY>, < KEITH, EVE>, < KEITH, ANNE>, < KEITH, JANE>, < KEITH, SUE>}

©P00482 - 2008 36
M
W
PETER 
PAUL   MARY

STEVE   EVE

JAMES   ANNE

GEORGE   JANE

KEITH   SUE

M x W =

{<PETER, MARY>, <PETER, EVE>, <PETER, ANNE>, <PETER, JANE>, <PETER, SUE>,
<PAUL, MARY>, <PAUL, EVE>, <PAUL, ANNE>, <PAUL, JANE>, <PAUL, SUE>,

<STEVE, MARY>, <STEVE, EVE>, <STEVE, ANNE>, <STEVE, JANE>, <STEVE, SUE>,

<JAMES, MARY>, <JAMES, EVE>, <JAMES, ANNE>, <JAMES, JANE>, <JAMES, SUE>,

<GEORGE, MARY>, <GEORGE, EVE>, <GEORGE, ANNE>, <GEORGE, JANE>, < GEORGE, SUE>,

<KEITH, MARY>, < KEITH, EVE>, < KEITH, ANNE>, < KEITH, JANE>, < KEITH, SUE>}

©P00482 - 2008 37
MARRIAGE  M x W =

{<PETER, ANNE>, <PAUL, JANE>, <STEVE, MARY>, < KEITH, SUE>}

RELATION ::=
a subset of cartesian product
where
for every pair (x, y) a pre-defined proposition p(x, y) holds true

attribute name

MARRIAGE HUSBAND WIFE


PETER ANNE attribute value
PAUL JANE
relation name
STEVE MARY
KEITH SUE tuple

©P00482 - 2008 38
PERSON-NAMES BIRTH-DATES
CITIES A relation R is a subset
of an
Smith

London
expanded cartesian product
Jones

of n, not necessarily
02-01-1950

distinct
Brown
Paris
03-01-1950

Green
.

. New York domains


D1 x D2 x ..., x Dn
Wilkes
.

30-12-1999
.

for every element


such that:
Tokyo
Tyler

dk = <dk1, dk2, ...,


dkn> R

attribute
a predefined proposition
(role) name

p(<dk1, dk2, ...,


dkn>)
PERSON40
NAME DOB CITY

d truei for every i=1,


isi D
k

2,...,n
Smith 02-11-1950 London

tuple (row)
Jones 22-03-1955 New York

relation
Brown 30-09-1972 Paris
k is a number of tuples in
name

the relation R (cardinality


of R)
attribute

column

©P00482 - 2008
value
n is a number of attributes
39

in the relation R (degree


domains

R - a relation defined by p(dk

on n domains D1 x ..., Dn,

so dk = <dk1, dk2, ..., dkn> R

R l R’

R’- a relation defined by p'(

on m domains Dj x ..., Dp,

entity so l = <dlj, ..., dlp> R' ;


occurrences

©P00482 - 2008 40
domains  is said to be a superkey
for R if and only if
p(dk) and p'(l) are
referentially equivalent,

i.e.
whenever p(dk) and p'(l)

R superkey R’ are both true,


dk and l refer to the same
entity occurrence,
in which case k = l
and  d is a bijection .

If m is minimal then
 is a proper candidate
©P00482 - 2008 key for R 41
REGISTER REGISTER’

ID NAME MOD-NO TITLE GRADE DATE ID MOD-NO


04123 John 8049 RDB 78 23/12/04 04123 8049
04123 John 8030 KBS 67 21/12/04 04123 8030
04567 Mary 8049 RDB 87 23/12/04 04567 8049

(ID, MOD-NO) is superkey for REGISTER

(ID, MOD-NO) is of minimal length (to identify any tuple)


and hence it is a proper (candidate) key

©P00482 - 2008 42
First Normal Form
STUDENT-RECORD
ST-REC

RECORD

ID NAME SUBJECT GRADE

ID NAME SUBJECT GRADE

S011 JOHN Mathematics B

S011 JOHN Mathematics B

S011 JOHN Programming A

Programming A

S011 JOHN Databases B

Databases B

S011 JOHN Data Structures C

Data Structures C

S173 MARY Electronics A


S173 MARY Electronics A

S173 MARY Prolog B


Prolog B

S173 MARY Mathematics A


Mathematics A

S112 PETER Programming C S112 PETER Programming C

Prolog A S112 PETER Prolog A

No attribute may be a structure - such as a table …

©P00482 - 2008 43
…or a list

MODULES-TAKEN
MODULES
ID
M1 M2 M3
S011 Mathematics Programming Databases Data Structures
S173 Electronics Prolog Mathematics
S112 Programming Prolog nil

MOD-TAKEN
ID MODULE
S011 Mathematics
S011 Programming
First Normal Form S011 Databases
S011 Data Structures
S173 Electronics
S173 Prolog
S173 Mathematics
S112 Programming
S112 Prolog
©P00482 - 2008 44
Entity Integrity

No prime attribute may hold a null value

DIRECTORY
FNAME SNAME ADDRESS TELEPHONE
John Adams 1 High Str 01234 123456
Mary Adams 11 North Av 01234 234567
x Adams 9 South Av 01234 345678
Peter x 5 Dore Clo 01234 456789
x x 13 Back Str 01234 567890

not allowed as senseless

©P00482 - 2008 45
Referential Integrity If a relation R includes a foreign key  match
the primary key  of some other relation M, th
every value of  in R must be equal to the val
of  in some tuple of R or br wholly null
REGISTER
S-ID SUBJECT GRADE
s011 Mathematics B
s011 Programming A
MODULE
s011 Databases B
SUBJECT LECTURER-ID
s011 Data Structures C
not allowed s011 Mathematics p123
Psychology A
Programming p234
s173 Computer Arch A
Data Structures p345
s173 Artificial Intell B
Databases p345
s173 Mathematics A
Computer Arch p123
s112 Programming C
Artificial Intell p567
s112 Artificial Intell A
primary key
foreign key
REGISTER.SUBJECT

MODULE.SUBJECT
©P00482 - 2008 46
RELATIONAL MODEL SUMMARY

• the only allowed structure is a relation exemplified


as a regular table (all tuples of identical format)
• all relations in any database are in 1NF - attribute
values are indivisible, i.e are not structures themselves
• no duplicate tuples in a relation
• order of tuples in a relation is immaterial
and cannot be used for any programming
• order of columns in a table is irrelevant - attributes are named
• access to any data item ensured via relation name,
attribute name, and primary key value and/or conditions
• no pointers or any other artificial reference objects -
all relationships between the data are represented solely
by attribute values
•Entity Integrity
•Referential Integrity

©P00482 - 2008 47
occupied_by
OFFICE LECTURER

NUMBER BUILDING ID NAME DOB ADDRESS …..

101 Main Block S027 Smith 21/3/56 London …..

C31 Science S128 Jones 4/6/50 Oxford …..

C43 Science S229 Brown 30/12/73 Abington …..

L01 Laboratory S341 Green 1/3/71 Oxford …..

ID NAME DOB ADDRESS ….. NUMBER BUILDING

S027 Smith 21/3/56 London ….. 101 Main Block

S128 Jones 4/6/50 Oxford ….. C31 Science

S229 Brown 30/12/73 Abington ….. C43 Science

S341 Green 1/3/71 Oxford ….. L01 Laboratory

X
N101 New Block

S678 Green 10/4/75 Oxford OK

NUMBER BUILDING ID NAME DOB ADDRESS …..


101 Main Block S027 Smith 21/3/56 London …..
C31 Science S128 Jones 4/6/50 Oxford …..
C43 Science S229 Brown 30/12/73 Abington …..
L01 Laboratory S341 Green 1/3/71 Oxford …..
©P00482 - 2008
N101 New Block OK 48
S678 Green 10/4/75 Oxford ….. X
foreign key

NUMBER BUILDING ID ID NAME DOB …..

101 Main Block S027 S027 Smith 21/3/56 …..

C31 Science S128 S128 Jones 4/6/50 …..

C43 Science S229 S229 Brown 30/12/73 …..

L01 Laboratory S341 S341 Green 1/3/71 …..

N101 New Block

S678 Green 10/4/75 …..

neither tuple exists

©P00482 - 2008 49
LECTURER counsels STUDENT

ID NAME ADDRESS ….. STNO NAME SEX …..

S027 Smith London ….. S011 John M …..

S128 Jones Oxford ….. S173 Mary F …..

S229 Brown Abington ….. S145 Ann F …..

S341 Green Oxford ….. A132 Paul M …..

S678 Green Oxford ….. S112 Peter M …..

S188 Neil M …..

S196 Mary F …..

STNO NAME SEX ID …..

S011 John M S027 …..

S173 Mary F S027 …..

S145 Ann F S027 …..

A132 Paul M S229 …..

S112 Peter M S229 …..

S188 Neil M S229 …..

S196 Mary F S678 …..

©P00482 - 2008 50
foreign

key
LECTURER decomposed MODULE

TEACHING

SCHEME

ID NAME ADDRESS ….. CODE TITLE REQUIRES

S027 Smith London ….. 8007 Pascal 8001

S128 Jones Oxford ….. 8011 Data Str 8021

S229 Brown Abington ….. 8012 OO Prog 8011

S341 Green Oxford ….. 8049 DB 8011

8050 MM 8012

foreign
foreign

key key

ID CODE …..

S027 8007 …..

S027 8049

S128 8007 …..

S229 8011 …..

S229 8012

©P00482 - 2008 51
S341 8011 …..

S341 8050 …..


prerequisite-for

MODULE

MODULE
CODE PREQ
........ ........

8003 8001
8002 8008
8008 8003

8011 8008

8012 8011 8010 8011

8010 8002

8025
8025 8011
8025 8012
8025
8025 8010

8029 8025
8027 8029
8027 8025 8047

........ ........

CODE PREQ
©P00482 - 2008 8047 8025
8025 new record 52
UNIVERSITY
MEMBER

UNIVERSITY
ID NAME DOB ADDRESS
MEMBER
super-entity
STUDENT
…….. …………. …….. ………….

LECTURER
exc_or

sub-entities
STUDENT LECTURER
ID HALL ENROL-DATE ID QUALIFIC SALARY

…….. …………. …………. …….. …………. ………….


…….. …………. …………. …….. …………. ………….

©P00482 - 2008 53
Referential Integrity Diagram

STUDENT
STNO NAME SEX DOB ADDRESS ENTRY

REGISTER
STNO CODE RESULT WHEN

MODULE
CODE TITLE REQUIRES TEACHID

LECTURER
ID NAME DOB ADDRESS QUALIF POSITION

OFFICE
ID NUMBER BUILDING

©P00482 - 2008 54

You might also like