Introduction to Database Systems. RHS – 2009 2 Why databases are important Because we use...
-
Upload
roderick-wilson -
Category
Documents
-
view
215 -
download
1
Transcript of Introduction to Database Systems. RHS – 2009 2 Why databases are important Because we use...
![Page 1: Introduction to Database Systems. RHS – 2009 2 Why databases are important Because we use databases all the time!! –Google –Youtube –Facebook –E-shopping.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649f135503460f94c27b7f/html5/thumbnails/1.jpg)
Introduction to Database Systems
![Page 2: Introduction to Database Systems. RHS – 2009 2 Why databases are important Because we use databases all the time!! –Google –Youtube –Facebook –E-shopping.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649f135503460f94c27b7f/html5/thumbnails/2.jpg)
RHS – 2009 2
Why databases are important
• Because we use databases all the time!!– Google– Youtube– Facebook– E-shopping– Banking
• Almost all private and official organisations use databasers, one way or another
Databases!
![Page 3: Introduction to Database Systems. RHS – 2009 2 Why databases are important Because we use databases all the time!! –Google –Youtube –Facebook –E-shopping.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649f135503460f94c27b7f/html5/thumbnails/3.jpg)
RHS – 2009 3
Why databases are important
• What is it, actually…?– A database is just a well-
structured collection of data, where data can be easily stored and retrieved
• Why is that useful…?– Data becomes information– Information becomes knowledge– Knowledge becomes wisdom
![Page 4: Introduction to Database Systems. RHS – 2009 2 Why databases are important Because we use databases all the time!! –Google –Youtube –Facebook –E-shopping.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649f135503460f94c27b7f/html5/thumbnails/4.jpg)
RHS – 2009 4
Types of Databases
• There are several types of database-systems:– Hierachical databases– Network-databases– Object-oriented databases– Relational databases
• Relational databases is by far the most common type, we will concentrate on that type in the following
![Page 5: Introduction to Database Systems. RHS – 2009 2 Why databases are important Because we use databases all the time!! –Google –Youtube –Facebook –E-shopping.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649f135503460f94c27b7f/html5/thumbnails/5.jpg)
RHS – 2009 5
Types of Databases
• Relational databases are (still) the most common type of database…
• …but does not fit perfectly with the object-oriented paradigm
• Mapping from object model to relational model is a very common task
• Why is this so…? Inertia, probably…
![Page 6: Introduction to Database Systems. RHS – 2009 2 Why databases are important Because we use databases all the time!! –Google –Youtube –Facebook –E-shopping.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649f135503460f94c27b7f/html5/thumbnails/6.jpg)
RHS – 2009 6
A database system is often called DBMS
• Data
• Base
• Management
• System
![Page 7: Introduction to Database Systems. RHS – 2009 2 Why databases are important Because we use databases all the time!! –Google –Youtube –Facebook –E-shopping.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649f135503460f94c27b7f/html5/thumbnails/7.jpg)
RHS – 2009 7
What is a DBMS…?
• A DBMS is the database itself, plus a number of programs used for interaction and maintenance of the database– Backup, restore– Performance monitoring– User interface– Interfaces to other programs– Etc.
![Page 8: Introduction to Database Systems. RHS – 2009 2 Why databases are important Because we use databases all the time!! –Google –Youtube –Facebook –E-shopping.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649f135503460f94c27b7f/html5/thumbnails/8.jpg)
RHS – 2009 8
Computer
What is a DBMS…?
Database
Maintenance
Performance
User Interface
Driver
![Page 9: Introduction to Database Systems. RHS – 2009 2 Why databases are important Because we use databases all the time!! –Google –Youtube –Facebook –E-shopping.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649f135503460f94c27b7f/html5/thumbnails/9.jpg)
RHS – 2009 9
ComputerComputer
What is a DBMS…?
Database
Maintenance
Performance
User Interface
Driver
![Page 10: Introduction to Database Systems. RHS – 2009 2 Why databases are important Because we use databases all the time!! –Google –Youtube –Facebook –E-shopping.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649f135503460f94c27b7f/html5/thumbnails/10.jpg)
RHS – 2009 10
Computer
ComputerComputer
What is a DBMS…?
Database
Maintenance
Performance
User Interface
Driver
![Page 11: Introduction to Database Systems. RHS – 2009 2 Why databases are important Because we use databases all the time!! –Google –Youtube –Facebook –E-shopping.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649f135503460f94c27b7f/html5/thumbnails/11.jpg)
RHS – 2009 11
What is a DBMS…?
• The exact physical configuration of database and programs is not as such important – it is a matter of setup
• No difference in functionality
• It is more relevant to think of such a system in terms of layers
![Page 12: Introduction to Database Systems. RHS – 2009 2 Why databases are important Because we use databases all the time!! –Google –Youtube –Facebook –E-shopping.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649f135503460f94c27b7f/html5/thumbnails/12.jpg)
RHS – 2009 12
What is a DBMS…?
User Interface
Maintenance
PerformanceDriver Database
Business LogicData processing
User inter-face layer
Business logic layer
DBMS layer
![Page 13: Introduction to Database Systems. RHS – 2009 2 Why databases are important Because we use databases all the time!! –Google –Youtube –Facebook –E-shopping.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649f135503460f94c27b7f/html5/thumbnails/13.jpg)
RHS – 2009 13
What is a DBMS…?
• A multi-layer (or multi-tier) structure is well suited for the Internet!
• Database on a central server, user interface through an Internet browser
• We use that every day!– Facebook– Net-banking– World of Warcraft…
![Page 14: Introduction to Database Systems. RHS – 2009 2 Why databases are important Because we use databases all the time!! –Google –Youtube –Facebook –E-shopping.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649f135503460f94c27b7f/html5/thumbnails/14.jpg)
RHS – 2009 14
DBMS – a closer look
• In many environments, it is absolutely critical that the DBMS functions perfectly!– Financial systems– Emergency systems– Traffic
• Perfectly – no persistent errors must become visible to the outside world
![Page 15: Introduction to Database Systems. RHS – 2009 2 Why databases are important Because we use databases all the time!! –Google –Youtube –Facebook –E-shopping.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649f135503460f94c27b7f/html5/thumbnails/15.jpg)
RHS – 2009 15
DBMS – a closer look
• Many functions in a DBMS handle error management and prevention– Transaction support– Concurrency management– Recovery services– Authorisation services– Integrity services
![Page 16: Introduction to Database Systems. RHS – 2009 2 Why databases are important Because we use databases all the time!! –Google –Youtube –Facebook –E-shopping.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649f135503460f94c27b7f/html5/thumbnails/16.jpg)
RHS – 2009 16
DBMS – Transactions
• A transaction is a set of changes to the state of the database
• Before the transaction, the database is in a valid and consistent state
• After the transaction, the database is in a valid and consistent state
• Example: Bank transfer
![Page 17: Introduction to Database Systems. RHS – 2009 2 Why databases are important Because we use databases all the time!! –Google –Youtube –Facebook –E-shopping.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649f135503460f94c27b7f/html5/thumbnails/17.jpg)
RHS – 2009 17
DBMS – Transactions
Account A:20000
Account B:10000
Transfers history:
Transfer 5000From A to B
![Page 18: Introduction to Database Systems. RHS – 2009 2 Why databases are important Because we use databases all the time!! –Google –Youtube –Facebook –E-shopping.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649f135503460f94c27b7f/html5/thumbnails/18.jpg)
RHS – 2009 18
DBMS – Transactions
Account A:20000
Account B:10000
Transfers history:
Step 1: Deduct 5000 from A
![Page 19: Introduction to Database Systems. RHS – 2009 2 Why databases are important Because we use databases all the time!! –Google –Youtube –Facebook –E-shopping.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649f135503460f94c27b7f/html5/thumbnails/19.jpg)
RHS – 2009 19
DBMS – Transactions
Account A:15000
Account B:10000
Transfers history:
Step 2: Deposit 5000 to B
![Page 20: Introduction to Database Systems. RHS – 2009 2 Why databases are important Because we use databases all the time!! –Google –Youtube –Facebook –E-shopping.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649f135503460f94c27b7f/html5/thumbnails/20.jpg)
RHS – 2009 20
DBMS – Transactions
Account A:15000
Account B:15000
Transfers history:
Step 3: Update transfers history
![Page 21: Introduction to Database Systems. RHS – 2009 2 Why databases are important Because we use databases all the time!! –Google –Youtube –Facebook –E-shopping.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649f135503460f94c27b7f/html5/thumbnails/21.jpg)
RHS – 2009 21
DBMS – Transactions
Account A:15000
Account B:15000
Transfers history:Transferred 5000 from A to B
![Page 22: Introduction to Database Systems. RHS – 2009 2 Why databases are important Because we use databases all the time!! –Google –Youtube –Facebook –E-shopping.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649f135503460f94c27b7f/html5/thumbnails/22.jpg)
RHS – 2009 22
DBMS – Transactions
• What if…– Power goes out between Step 1 and 2– A disk error occurs– …
• In any case, the database could be left in an inconsistent state!
• For a transaction, either none or all of the steps must be completed
![Page 23: Introduction to Database Systems. RHS – 2009 2 Why databases are important Because we use databases all the time!! –Google –Youtube –Facebook –E-shopping.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649f135503460f94c27b7f/html5/thumbnails/23.jpg)
RHS – 2009 23
DBMS – Transactions
• In general, transactions must be ACID:– Atomic – either all steps or none– Consistent – leaves the database in a
consistent state– Isolated – other processes cannot see a
transaction ”in progress”– Durable – the change is permanent (but the
affected data may of course be updated later)
![Page 24: Introduction to Database Systems. RHS – 2009 2 Why databases are important Because we use databases all the time!! –Google –Youtube –Facebook –E-shopping.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649f135503460f94c27b7f/html5/thumbnails/24.jpg)
RHS – 2009 24
DBMS – Concurrency
• Concurrency management is somewhat related to transaction
• The DBMS must be able to allow multiple clients concurrent access to the database
• No problem when reading data
• Becomes tricky when clients are writing data…
![Page 25: Introduction to Database Systems. RHS – 2009 2 Why databases are important Because we use databases all the time!! –Google –Youtube –Facebook –E-shopping.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649f135503460f94c27b7f/html5/thumbnails/25.jpg)
RHS – 2009 25
DBMS – Concurrency
• The DBMS must ”lock” certain parts of the data in the database, when a uses wants to update it
• May cause requests to queue up…
• Conflicting goals:– Ensure consistency (lock enough)– Ensure efficiency (lock only what is needed)
![Page 26: Introduction to Database Systems. RHS – 2009 2 Why databases are important Because we use databases all the time!! –Google –Youtube –Facebook –E-shopping.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649f135503460f94c27b7f/html5/thumbnails/26.jpg)
RHS – 2009 26
DBMS – Recovery
• In case of failure (of any kind), the DBMS must be able to recover the database
• Recover: When DBMS is back online, the database must be in a consistent state
• Often achieved by using duplicate databases, either online or offline
• Online duplicate enables immediate recovery
![Page 27: Introduction to Database Systems. RHS – 2009 2 Why databases are important Because we use databases all the time!! –Google –Youtube –Facebook –E-shopping.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649f135503460f94c27b7f/html5/thumbnails/27.jpg)
RHS – 2009 27
DBMS – Authorisation
• Many databases contain sensitive data
• We may wish to limit the actions a specific user can perform on the database
• Such user rights can be defined on several levels
![Page 28: Introduction to Database Systems. RHS – 2009 2 Why databases are important Because we use databases all the time!! –Google –Youtube –Facebook –E-shopping.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649f135503460f94c27b7f/html5/thumbnails/28.jpg)
RHS – 2009 28
DBMS – Authorisation
• User rights– Only read data, or read and write– Only work with certain parts of data– Only do certain updates to data– Only allowed to do maintenance– And so on…
• User rights are often defined in terms of defining user roles
![Page 29: Introduction to Database Systems. RHS – 2009 2 Why databases are important Because we use databases all the time!! –Google –Youtube –Facebook –E-shopping.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649f135503460f94c27b7f/html5/thumbnails/29.jpg)
RHS – 2009 29
DBMS – Authorisation
Role
Actions
Admini-strator
Mainte-nance
Super-user Manager Empolyee
Add/delete
tables Yes No No No No
Make Backup Yes Yes No No No
Write dataYes No Yes No No
Write data
(predefined) Yes No Yes Yes No
Read dataYes No Yes Yes Yes
![Page 30: Introduction to Database Systems. RHS – 2009 2 Why databases are important Because we use databases all the time!! –Google –Youtube –Facebook –E-shopping.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649f135503460f94c27b7f/html5/thumbnails/30.jpg)
RHS – 2009 30
DBMS – Integrity
• Data can be incorrect on multiple levels
• Each piece of data can be correct as such, but a collection of data might be inconsistent
• Can be handled using constraints on data
![Page 31: Introduction to Database Systems. RHS – 2009 2 Why databases are important Because we use databases all the time!! –Google –Youtube –Facebook –E-shopping.](https://reader036.fdocuments.in/reader036/viewer/2022062518/56649f135503460f94c27b7f/html5/thumbnails/31.jpg)
RHS – 2009 31
DBMS – Integrity
• A constraint can specify cross-field consistency rules
• ”Sum of fields 2- 10 may not exceed value in field 1”
• ”Field 2 must at most be half of field 1”
• Updates that will break a constraint are not allowed by the DBMS