Course organisation TDDC94 Database Technology TDDI60 Technical Databases Responsible:

advertisement
Responsible:
2000-01-26
Lena Strömbäck
lestr@ida.liu.se
IISLAB
IDA
Lena Strömbäck
lestr@ida.liu.se
IISLAB
IDA
TDDC94 Database Technology
TDDI60 Technical Databases
Course organisation
•
12 lectures (TDDI60 8 lectures)
•
Written exam
•
Lab exercises
-
Lena Strömbäck
3 computer labs
1 paper lab
Mini project
http://www.ida.liu.se/~TDDC94
augusti 2007
1
1
Lena Strömbäck
lestr@ida.liu.se
IISLAB
IDA
Examiner:
ƒ
•
ƒ One group have two rooms.
ƒ Paper lab scheduled in lecture rooms.
•
•
Teachers:
Lena Strömbäck, lestr@ida.liu.se
Tommy Ellkvist, g-tomel@ida.liu.se
Almut Herzog, almhe@ida.liu.se
José M Pená, jmp@ida.liu.se
3
3
augusti 2007
4
4
Lena Strömbäck
lestr@ida.liu.se
IISLAB
IDA
Laboratory information
•
You need a special database account
ƒ automatically created at course registration
ƒ e-mail system@ida.liu.se if any problems
Handing in labs
•
Each lab requires a written report
•
Labs can be handed in:
ƒ
ƒ
•
•
5
5
augusti 2007
6
To the teacher at the lab
At IDAs postboxes, opposite to Café Java
Labs can be fetched:
ƒ
ƒ
ƒ
Subscribe for labs via course home page
ƒ Choose your course code (TDDC94, TDDI60)
ƒ Use groups A and B as far as possible
ƒ OLD-gr, discuss with Lena before choosing this group
augusti 2007
Mini-project: Less supervision.
Katarina Löfstrand, katlo@ida.liu.se
Director of studies:
ƒ
ƒ
ƒ
Lab schedule on the course web-page.
He Tan, hetan@ida.liu.se
•
ƒ
Lena Strömbäck
lestr@ida.liu.se
IISLAB
IDA
•
Lena Strömbäck, lestr@ida.liu.se
Course administration:
ƒ
augusti 2007
Laboratory schedule
Course leader and Course assistant
ƒ
•
2
2
Lena Strömbäck
lestr@ida.liu.se
IISLAB
IDA
Course leadership
•
augusti 2007
From the teacher at the lab
At the OUT box outside each teachers office
Remember to fetch your labs, it is your only proof that you have passed the
labs.
6
1
Responsible:
2000-01-26
Lena Strömbäck
lestr@ida.liu.se
IISLAB
IDA
Labs reports deadlines
•
Lab reports are handed in:
ƒ
ƒ
ƒ
ƒ
ƒ
ƒ
augusti 2007
•
Last day for handing in: Oct 14th
•
Next occasions: Jan 10th, August 2007
•
Later: Redo the labs!!!
Two parts:
ƒ
ƒ
ƒ
•
•
8
Elmasri, R., Navathe, S., Fundamentals of Database
Systems, 5th edition, Addison-Wesley, ISBN 0-32148506-X, 2006
Course overview – Part1
•
Introduction and ER-modeling (Lena)
•
The Relational Model (José)
•
SQL (José)
•
EER and mapping ER/EER to relational, Intro to transactions (José)
ƒ
•
Lab compendium: Databases, ADIT-1, version autumn
2006
ƒ
ƒ
9
Lena Strömbäck
lestr@ida.liu.se
IISLAB
IDA
Functional dependencies and normalization (Almut)
SQLPSM, triggers and stored procedures (José)
Mini-project implementation
•
Data structures for databases (He)
•
Data Structures for Databases II (NOT TDDI60) (He)
•
Transactions and Concurrency Control (NOT TDDI60) (Almut)
•
Database Recovery (NOT TDDI60) (Almut)
•
Query Processing and Optimization (NOT TDDI60) (Almut)
•
Summary and Outlook; (Lena)
ƒ
augusti 2007
11
Lab3: Normalization
Lab4: Stored Procedures
10
10
Lena Strömbäck
lestr@ida.liu.se
IISLAB
IDA
Course overview - Part 2
•
augusti 2007
Lab2: Database Design and ER/modeling
Start with modeling part of the mini project!
•
ƒ
9
Lab1: SQL-queries and view
•
ƒ
augusti 2007
Studentportalen
Last date: 2006-10-03
8
Lena Strömbäck
lestr@ida.liu.se
IISLAB
IDA
Course literature
Dictionary – not electronic
No calculator
No books allowed
Registration to the exam
ƒ
ƒ
augusti 2007
Theoretical and practical
Have to pass both parts
For TDDI60: Some theoretical questions
Equipment
ƒ
ƒ
ƒ
7
•
Written exam
•
Lab1: Week 35
Lab2: Week 36
Lab3: Week 37
Lab4: Week 38
Project: Model Week 37
Project: Implementation Week 41
7
Lena Strömbäck
lestr@ida.liu.se
IISLAB
IDA
Lena Strömbäck
lestr@ida.liu.se
IISLAB
IDA
Today´s lecture
•
Database introduction and terminology
•
EER-modelling
Mandatory occasion on modeling sept 21st
11
augusti 2007
12
12
2
Responsible:
2000-01-26
Lena Strömbäck
lestr@ida.liu.se
IISLAB
IDA
augusti 2007
What is a database?
One way to store data in electronic format.
•
•
Used in ordinary life, banks, booking of hotels or travels,
search in the library, shopping.
A database represents some aspect of the real world, i.e.
a mini world.
•
•
New applications: multimedia databases, geographical
information systems, real time databases
A database consists of a logical coherent collection of
data with an underlying meaning.
•
A database is designed, built and filled with data with
respect to an underlying purpose.
13
13
File storage:
223344-5566PELLE PERSSON STIGSTIGEN 11
334455-6677ANNA ANDSSON
augusti 2007
GATGATAN 3
LINDESBERG
17
augusti 2007
•
Flat files not a good way for storing complex data. Not flexible.
(Solution data modelling)
•
Inefficiency when replacing hard- or software.
(Solution data independence)
•
Problems with handling many users that want to change the data.
(Solution transactions)
•
Users might want to see and have access to different parts of the data.
(Solution views)
•
Data should be persistent over time.
(Solution recovery)
•
Efficient storage of large quantities of data.
(Solution indexing)
Hierarchical databases
17
augusti 2007
16
16
Lena Strömbäck
lestr@ida.liu.se
IISLAB
IDA
Early database models:
•
Problems with file storage
ÖREBRO
15
Network databases
14
14
KLARKÖPING
15
•
augusti 2007
Lena Strömbäck
lestr@ida.liu.se
IISLAB
IDA
112233-4455KALLE KARLSSON VÄGVÄGEN 13
Lena Strömbäck
lestr@ida.liu.se
IISLAB
IDA
What is a database? - Definition
•
Lena Strömbäck
lestr@ida.liu.se
IISLAB
IDA
augusti 2007
Lena Strömbäck
lestr@ida.liu.se
IISLAB
IDA
18
70:s The relational model
•
Data stored as tables.
•
Theoretical model.
•
Standardised query language.
•
In the beginning these kind of databases where slow.
Hierarchical databases faster.
18
3
Responsible:
2000-01-26
Lena Strömbäck
lestr@ida.liu.se
IISLAB
IDA
Lena Strömbäck
lestr@ida.liu.se
IISLAB
IDA
More recent databases
•
Object oriented databases (80:s)
- model: persistent objects,
messages, encapsulation, inheritance
augusti 2007
Object-relational databases (90:s)
•
XML-databases (00:s)
19
19
Lena Strömbäck
lestr@ida.liu.se
IISLAB
IDA
augusti 2007
•
Databases
•
database management system (DBMS): A number of
programs that allows a user to create and support a
database
•
database system = database + database management
system
•
Relational databases dominating.
•
Hierarchical databases still in use. (Mainly in flight
industry.)
•
Object-oriented databases in use, especially as objectrelational databases.
•
XML-databases – new, first commercial products
appearing.
20
20
Lena Strömbäck
lestr@ida.liu.se
IISLAB
IDA
DBMS - benefits
ƒ
ƒ
ƒ
ƒ
ƒ
ƒ
ƒ
ƒ
ƒ
21
21
Lena Strömbäck
lestr@ida.liu.se
IISLAB
IDA
augusti 2007
Today:
augusti 2007
22
22
Lena Strömbäck
lestr@ida.liu.se
IISLAB
IDA
Architecture - three levels of data
Control of redundant information
Data access
Persistent data storage
Allow questions and inference
Allow several users
Representation of complex data relations
Efficient storage of data
Integrity Constraints
Backup and recovery.
Handling many users
Pelle
Data independence between the levels
Sums total
salary costs
View
View
View
Kalle
Conceptual level
Updates the
salary for 1000
employees
Database
Physical level
augusti 2007
23
23
augusti 2007
24
24
4
Responsible:
2000-01-26
Lena Strömbäck
lestr@ida.liu.se
IISLAB
IDA
Lena Strömbäck
lestr@ida.liu.se
IISLAB
IDA
Persistency and errors
Power failure
Course goals (1)
•
Understand the important concepts within databases and
database terminology
•
Design a database for a given application
•
Design and use a relational database
ƒ
ƒ
ƒ
ƒ
ƒ
Kalle
Updates the
salary
for 1000
employees
augusti 2007
25
26
26
Theoretical foundations behind relational databases
ƒ
ƒ
ƒ
•
augusti 2007
Lena Strömbäck
lestr@ida.liu.se
IISLAB
IDA
Course goals (2)
•
Course goals (3)
•
Relational algebra
How these have impact on database implementation (Only TDDB38)
Query optimisation (Only TDDB38)
Understand how databases can support multiple users
ƒ
ƒ
ƒ
ƒ
Understand how the database is stored on the computer
ƒ
ƒ
ƒ
Concept of relations
Use SQL
Use MySQL
Decipher a new relational database system
Database
25
Lena Strömbäck
lestr@ida.liu.se
IISLAB
IDA
EER-modelling
Basic technology, file structures, indexing
Impact on database performance
B-Trees, Hashing (Only TDDB38)
•
What problems occur
Views
Transactions
Serialisation (only TDDB38)
Understand how persistency can be guaranteed. (only
TDDB38)
ƒ Recovery
augusti 2007
27
27
augusti 2007
Lena Strömbäck
lestr@ida.liu.se
IISLAB
IDA
Databases
28
28
ER modelling
User 4
Real World
Model
Updates
UserQueries
3 Answers
Updates
UserQueries
2 Answers
UserQueries
1 Answers
Updates
Updates Queries Answers
Personal number Address
Database
Database
management
system
Processing of
queries and updates
Name
Access to stored data
E-mail
Telephone
Age
Physical
database
augusti 2007
30
30
5
Responsible:
2000-01-26
Lena Strömbäck
lestr@ida.liu.se
IISLAB
IDA
ER diagrams
Candidate keys
Attribute
•
A conceptual model
•
A structured way of modelling data.
•
Independent of database type.
•
Documentation of your structure.
E-mail
E-mail
Composite
attributes
PNummer
Entity
GName
Employee
Name
FName
Age
Free
Multiple valued
attribute
Derived attribute
augusti 2007
31
31
Relations
Total participation
Pnum
Dnum
Employee
Employed
at
Department
Dnum
Pnum
Employed
at
Employee
Department
“Every department must have at least one employee”
“Employees are employed at departments”
Total participation
Cardinalities
Pnum
Dnum
Pnum
Dnum
N
Employee
Employed
at
Department
“Every employee must belong to a department”
Employee
Employed
at
1
Department
“Each department have many employees, but each employee
can only belong to one department”
6
Responsible:
2000-01-26
Cardinalities
Cardinalities
Pnum
Dnum
1
N
Employed
at
Employee
Pnum
N
Department
Dnum
(1,1)
Employed
at
(1,100)
Pnum
Employee
Employed
at
1
Department
“Employees are identified through their departments,
i.e. Salesman John”
Lena Strömbäck
lestr@ida.liu.se
IISLAB
IDA
ER-example 1
Persons lives at an address.
41
Dnum
N
Department
“Each department have up to 100 employees, but each employee
can only belong to one department”
augusti 2007
Department
Weak entities
Pnum
ƒ
M
“Each department have many employees, and each employee
can belong to many departments”
Cardinalities
Lena Strömbäck
lestr@ida.liu.se
IISLAB
IDA
Employed
at
Employee
“Each department have one employee, but each employee
can belong to many departments”
Employee
Dnum
ER-example 2
Books are written by one or more authors.
Are addresses important in the database?
ƒ Are authors important in the database?
ƒ Can you talk about the author without mentioning the book?
41
augusti 2007
42
42
7
Responsible:
2000-01-26
Lena Strömbäck
lestr@ida.liu.se
IISLAB
IDA
Lena Strömbäck
lestr@ida.liu.se
IISLAB
IDA
ER-example 3
ER Example 4:
Customers can rent video films.
Students take courses and study at study programs with
different length. A study program consists of a set of
courses. Students are identified by their e-mail address.
A course is identified by its course code and the student
earn a number of points when they have taken the
course.
ƒ Is the rental history important?
ƒ Can the same video be rented more than once?
augusti 2007
43
43
Lena Strömbäck
lestr@ida.liu.se
IISLAB
IDA
augusti 2007
44
44
EER-modelling
•
Adding inheritance to ER-diagrams
Technichian
ENumber
Teleph.
Spec.
Lang.
Salary
ENumber
augusti 2007
Administrator
Teleph.
Salary
45
45
ENumber
Employee
Employee
Salary
Teleph.
d
Technician
ENumber
Teleph.
d
Spec.
Administrator
Salary
ENumber
Technician
Lang.
ENumber
Teleph.
Salary
Teleph.
Spec.
Administrator
Lang.
Salary
ENumber
Teleph.
Salary
8
Responsible:
2000-01-26
Disjoint inheritance
Full participation
ENumber
ENumber
Employee
Employee
Salary
Teleph.
d
Technician
Spec.
d
Administrator
Lang.
Technician
Spec.
Overlapping inheritance
Multiple inheritance
ENumber
ENumber
Employee
Spec.
Salary
Teleph.
o
Technician
Lang.
Employee
Salary
Teleph
Administrator
“All employees must be either a technician or an administrator”
“Employees can be either technicians (x)or administrators”
o
Administrator
Lang.
“There are employees that are both technicians and administrators”
Lena Strömbäck
lestr@ida.liu.se
IISLAB
IDA
Salary
Teleph.
Technician
Spec.
AdmTechn
Administrator
Lang.
Procent
Example 2:
At the university there are two kinds of students, graduate
and undergraduate Dependent on which category a
student belong, a different set of courses are available.
Some courses are available only for graduate students,
some only for undergraduate and some for all students.
augusti 2007
53
53
9
Download