INFO1408 Database Design Concepts Week 16: Introduction to Database Management Systems Continued.

Slides:



Advertisements
Similar presentations
Manipulating Data Schedule: Timing Topic 60 minutes Lecture
Advertisements

Lock-Based Concurrency Control
Lecture 9 Descriptors, Events & Event Tables INFO1409 Systems Analysis & Design Module HND Year /9.
Distributed Databases John Ortiz. Lecture 24Distributed Databases2  Distributed Database (DDB) is a collection of interrelated databases interconnected.
Transaction Processing. Objectives After completing this lesson, you should be able to do the following: –Define transactions effectively for an application.
Distributed Databases Logical next step in geographically dispersed organisations goal is to provide location transparency starting point = a set of decentralised.
A Guide to SQL, Seventh Edition. Objectives Create a new table from an existing table Change data using the UPDATE command Add new data using the INSERT.
Database Administration Chapter Six DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition.
Transaction Management and Concurrency Control
Transaction Management and Concurrency Control
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
Chapter 8 : Transaction Management. u Function and importance of transactions. u Properties of transactions. u Concurrency Control – Meaning of serializability.
TRANSACTIONS. Definition One or more SQL statements that operate as a single unit. Each statement in the unit is completely interdependent. If one statement.
Database Design Concepts Info 1408 Lecture 2 An Introduction to Data Storage.
Database Design Concepts INFO1408 Term 2 week 1 Data validation and Referential integrity.
A Guide to MySQL 7. 2 Objectives Understand, define, and drop views Recognize the benefits of using views Use a view to update data Grant and revoke users’
A Guide to SQL, Seventh Edition. Objectives Understand, create, and drop views Recognize the benefits of using views Grant and revoke user’s database.
Database Administration Part 1 Chapter Six CSCI260 Database Applications.
Functions of a Database Management System. Functions of a DBMS C.J. Date n Indexing n Views n Security n Integrity n Concurrency n Backup/Recovery n Design.
Databases and Database Management Systems
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
Transaction Management WXES 2103 Database. Content What is transaction Transaction properties Transaction management with SQL Transaction log DBMS Transaction.
© 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 CHAPTER 11: DATA AND DATABASE ADMINISTRATION Modern Database Management 11 th Edition Jeffrey.
Multi-user Database Processing Architectures Architectures Transactions Transactions Security Security Administration Administration.
Concepts of Database Management, Fifth Edition
Security, Transactions, and Views. Security Achieved through GRANT & REVOKE Assumes the database can recognize its users and verify their identity can.
What to do for a Financial year end And When to do it.
Database Management System Module 5 DeSiaMorewww.desiamore.com/ifm1.
Management Information Systems MS Access MS Access is an application software that facilitates us to create Database Management Systems (DBMS)
BIS Database Systems School of Management, Business Information Systems, Assumption University A.Thanop Somprasong Chapter # 10 Transaction Management.
1099 Why Use InterBase? Bill Todd The Database Group, Inc.
Transaction processing Book, chapter 6.6. Problem: With a single user…. you run a query, you get the results, you run the next, etc. But database life.
Chapter 15 Recovery. Topics in this Chapter Transactions Transaction Recovery System Recovery Media Recovery Two-Phase Commit SQL Facilities.
Security, Transactions, and Views. About Security As is the case in most shared environments, the DBMS also must implement a security mechanism that allows.
1 IRU Concurrency, Reliability and Integrity issues Geoff Leese October 2007 updated August 2008, October 2009.
MS Access 2007 Management Information Systems 1. Overview 2  What is MS Access?  Access Terminology  Access Window  Database Window  Create New Database.
Ch 10: Transaction Management and Concurrent Control.
1 IT420: Database Management and Organization Session Control Managing Multi-user Databases 24 March 2006 Adina Crăiniceanu
Concurrency Control in Database Operating Systems.
Chapter 1 Introduction to Databases. 1-2 Chapter Outline   Common uses of database systems   Meaning of basic terms   Database Applications  
INFO1408 Database Design Concepts Week 15: Introduction to Database Management Systems.
Transactions and Locks A Quick Reference and Summary BIT 275.
Database structure and space Management. Segments The level of logical database storage above an extent is called a segment. A segment is a set of extents.
© 2002 by Prentice Hall 1 Database Administration David M. Kroenke Database Concepts 1e Chapter 6 6.
The Relational Model1 Transaction Processing Units of Work.
IT Database Administration Section 09. Backup and Recovery Backup: The available options Full Consistent (cold) Backup Database shutdown, all files.
INFO1002 Systems Modelling Lecture 10 Establishing User Requirements Department of information Systems.
CSC 240 (Blum)1 Database Transactions. CSC 240 (Blum)2 Transaction  A transaction is an interaction between a user (or application) and a database. A.
Section 06 (a)RDBMS (a) Supplement RDBMS Issues 2 HSQ - DATABASES & SQL And Franchise Colleges By MANSHA NAWAZ.
Chapter 15: Reliability and Security in Database Servers Neyha Amar CS 157B May 6, 2008.
CSC 411/511: DBMS Design Dr. Nan WangCSC411_L12_JDBC_MySQL 1 Transations.
Introduction to Distributed Databases Yiwei Wu. Introduction A distributed database is a database in which portions of the database are stored on multiple.
A Guide to SQL, Eighth Edition Chapter Six Updating Data.
©Bob Godfrey, 2002, 2005 Lecture 17: Transaction Integrity and Concurrency BSA206 Database Management Systems.
3 Database Systems: Design, Implementation, and Management CHAPTER 9 Transaction Management and Concurrency Control.
10 1 Chapter 10 - A Transaction Management Database Systems: Design, Implementation, and Management, Rob and Coronel.
A Guide to MySQL 6. 2 Objectives Create a new table from an existing table Change data using the UPDATE command Add new data using the INSERT command.
SQL Triggers, Functions & Stored Procedures Programming Operations.
Topics in Distributed Databases Database System Implementation CSE 507 Some slides adapted from Navathe et. Al and Silberchatz et. Al.
Chapter 13 Managing Transactions and Concurrency Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition.
SYSTEMS IMPLEMENTATION TECHNIQUES TRANSACTION PROCESSING DATABASE RECOVERY DATABASE SECURITY CONCURRENCY CONTROL.
Copyright © 2016 Pearson Education, Inc. CHAPTER 12: DATA AND DATABASE ADMINISTRATION Modern Database Management 12 th Edition Jeff Hoffer, Ramesh Venkataraman,
Cosc 5/4765 Database security. Database Databases have moved from internal use only to externally accessible. –Organizations store vast quantities of.
Distributed Databases – Advanced Concepts Chapter 25 in Textbook.
Physical Changes That Don’t Change the Logical Design
Functions of a Database Management System
Chapter 10 Transaction Management and Concurrency Control
Introduction of Week 13 Return assignment 11-1 and 3-1-5
Database Administration
IST 318 Database Administration
Presentation transcript:

INFO1408 Database Design Concepts Week 16: Introduction to Database Management Systems Continued

Last week we talked about database features This week we are going to look in more detail at three of these features: 1.Improving security –Privileges –Views 2.Recovery From Failure –Commit and Rollback 3.Concurrency Control (dealing with many users) –Locking –Deadlock. 2

3 1. Improving Security

4 Database access security Prevent unauthorised access to the database This means making sure users can only access the data that they need This is done by granting privileges - users are given the rights to add, amend, delete etc if they need to do this - otherwise they cannot carry out the operation The other main method of restricting access to information is the use of views.

5 Definition of a view A view is the result of a query This is displayed to the user as if it is a table, and can be used like a table The view restricts the columns and/or rows of the original table that the user has access to A view can be made up of several tables (by including a join in the query). This can reduce the complexity for the user.

6 Reasons for using a view Hiding columns and/or rows that the user does not need (or should not be allowed to see). If someone does not know the data is there they will not be tempted to access it Hiding complex database operations from the user. (This also makes it more difficult for users to work out the structure of the database) May improve the performance (speed) of a query that the user carries out on the view.

7 Example A user in the database department wishes to allocate staff to jobs/projects This needs the employee table. We do not want the user to see the employees’ salaries.

8 Employee Table Employee- number Employee- name SkillsDepartmentSalary Andy Oppel SecurityDatabase£ David HoweDesignDatabase£ SatzingerDesignSystems£3500

9 We can create a view so that the employees’ salaries are not shown to the user CREATE VIEW Emp AS SELECT Employee-number, employee- name, skills, department FROM employee; Note that Salary is not included in the query.

10 The Resulting View (Emp View) Employee- number Employee- name SkillsDepartment Andy Oppel SecurityDatabase David Howe DesignDatabase SatzingerDesignSystems

11 If we decide the user can only look at employees in their own department we add a WHERE clause to the SELECT statement to limit the number of rows: SELECT Employee-number, employee- name, skills, department FROM employee WHERE department=’Database’;

12 Emp View (version 2) Employee- number Employee- name SkillsDepartment Andy Oppel SecurityDatabase David Howe DesignDatabase

13 Views can also make things simpler for the user In the last example the user may also need to inform the employee’s manager Details of departmental managers are held in another table (called Manager) We can create a view which presents all the information for the user to complete this task, by joining the two tables in a query.

Manager Table Manager-NameDepartment HofferSystems DateDatabase 14

15 Emp View (version 3) Employee- number Employee- name SkillsDepartmentManager Andy Oppel SecurityDatabaseDate David Howe DesignDatabaseDate

16 2. Recovery from Failure

17 Recovering from Failure All systems will fail at some time Organisations need procedures to make it easy to get the system up and working again with minimal disruption This is dealt with using back-up and recovery procedures – just as you do with your work!!

18 Transaction Logs Large databases keep transaction logs These logs record all the work which has been carried out since the last back-up. The log can be used to redo all this work if necessary.

19 Transactions A transaction is defined as a unit of work. The important thing to remember is we do all or none of it This could be quite simple such as changing the name of a customer.

20 A transaction can be complex involving many updates to different tables – the user triggers the transaction once and works through it to the end It is these complex transactions that make life difficult. If there is a system failure, how do we know which parts of the transaction have been completed? In other words where to start again? Complex Transactions

21 An Example A user is carrying out a transaction which involves inputting a new product This involves: 1. Adding the product details (product number, description, quantity in stock, who the supplier is, price they will pay the supplier for the product, and the price they will sell it for) 2. Updating the supplier’s record so that they can be paid for what they have supplied 3. Calculating a discount (as it is a new product) 4. Updating the website with the new product’s details.

22 The system fails when the user is part-way through stage 4 This means: –the new product has been entered into the system –the supplier’s record shows that the supplier is owed an amount of money –the discount price has been calculated and is on the database –but the product has not yet been added to the website BUT the user does not know exactly when the failure occurred. The user has three options….

23 1. Assume they have finished the transaction –This means that customers will not know about the product OR 2. Start the transaction again from the beginning –This means that the supplier gets paid twice and the discount is recalculated reducing the price by even more, but customers will know about the product OR 3. The user guesses where to start again –This gives a combination of problems.

24 This situation is obviously not OK We need to ensure the integrity of our database (so that we can trust the information the database supplies) We achieve this by using a feature usually included as part of the DBMS.

25 Commit The transaction log records when each transaction starts and what changes it makes to the database When the transaction is completed a command called COMMIT is issued which makes all the changes permanent, and records the transaction as complete in the log.

26 Rollback When there is a system failure the DBMS looks through the transaction log and finds transactions that have been started but do not have a COMMIT These transactions are undone using the transaction log to put the database back how it was before the failure – this process is known as ROLLBACK.

27 3. Dealing with Many Users

28 Dealing with many users We have covered some of the things organisations do to protect their databases from malicious and accidental damage They do this is to ensure the integrity of the database (i.e. that it is available and reliable) There is one more possible problem with multi-user systems Consider this situation…….

29 Two users wish to enter an order for the same item (pencils) at the same time. There are 4,000 in stock –User A’s order is for 200 pencils –User B’s order is for 250 pencils User A is given a value of 4000 pencils in stock. This value is amended to 3800 and committed to the database Before user A has committed their transaction user B has also been given the value of 4000 which they amend to 3750 This transaction is also committed and overwrites the value in the attribute (setting it to 3750) The database is left with wrong information - it should say 3550.

30 How does the DBMS stop this problem? This is dealt with by locking part of the database The DBMS does not allow other users into that area until the lock is removed There are different levels of locking. The person responsible for the database must decide when to apply which level There are several alternatives……..

31 Database locking –If any user is accessing the database no one else can. Rarely used – too disruptive Table locking –If a user is accessing a table other users are locked out from the table. Again this may be too inconvenient if there are many users Block or Page locking –An operating system puts blocks or pages of data into memory. If a user has accessed a part of the database the rest of the data read into memory at the same time will not be available to other users.

32 Record or row locking –Lock users from accessing a record if someone else is using it. The most common as it minimises disruption to users without taking too much effort to manage Column or attribute level locking –Lock users from accessing an attribute if someone else is using it. Sounds good in theory but very difficult to manage - slows the system down - deadlocks are more common (explained later).

33 Using our previous example - assuming record level locking User A requests the record for pencils which gives the user the value of 4000 for quantity in stock of The record is locked User B requests the same record which is locked. They have to wait User A completes their transaction, Quantity in stock is amended to 3800, the transaction is committed and the lock removed User B is given the updated record and amends the quantity in stock to It is locked from other users until the COMMIT command is received.

34 Deadlock There is one potential problem with locking called a deadlock This is when two users cannot complete their transactions (and release the lock) because they are each waiting for the other to release the lock on another record - it sounds complicated so we will use an example.

35 Assuming column or attribute level locking User A works in the purchasing section of an organisation. The transaction involves updating the quantity in stock then updating the price of the item User B works in the finance section and is processing a customer’s order. This involves finding out the price of an item and then checking the quantity in stock.

36 Database user A Select and update quantity in stock (lock attribute) Database user B Select price of item (lock attribute) Select and update price of item (must wait due to user B’s lock) Select and update quantity in stock (must wait due to user A’s lock) DATABASEDATABASE

37 In this situation both users could wait forever for the other to release the lock This fortunately is dealt with by the DBMS. The DBMS looks for deadlock situations and usually terminates one of the transactions involved and rolls back the transaction.

38 Summary You should now be able to describe the following terms: –Security privileges and views –COMMIT and ROLLBACK commands to recover from failure –Explain locking –Explain what is meant by deadlock.