Function
Transcript of Function
![Page 1: Function](https://reader031.fdocuments.in/reader031/viewer/2022032420/55a4e3001a28abef648b4597/html5/thumbnails/1.jpg)
Functions of a Database Management System
![Page 2: Function](https://reader031.fdocuments.in/reader031/viewer/2022032420/55a4e3001a28abef648b4597/html5/thumbnails/2.jpg)
Functions of a DBMSC.J. Date
� Indexing� Views� Security� Integrity� Concurrency
� Backup/Recovery� Design� Documentation� Update/Query
![Page 3: Function](https://reader031.fdocuments.in/reader031/viewer/2022032420/55a4e3001a28abef648b4597/html5/thumbnails/3.jpg)
Views
Custom representations of a database that correspond to the
needs of a class of users. Stored SELECT statements.
![Page 4: Function](https://reader031.fdocuments.in/reader031/viewer/2022032420/55a4e3001a28abef648b4597/html5/thumbnails/4.jpg)
Views
� Views Provide: representations of data for different users to • protect data quality • insulate users from changes in
structure
CREATE VIEW
VIEWNAME {VIEW ATTRIBUTES}
AS (SELECT ..WHERE ..)
![Page 5: Function](https://reader031.fdocuments.in/reader031/viewer/2022032420/55a4e3001a28abef648b4597/html5/thumbnails/5.jpg)
Views
Views Permit� Maintaining a constant user interface � Restricting access to specified
attributes� Specifying user rights
![Page 6: Function](https://reader031.fdocuments.in/reader031/viewer/2022032420/55a4e3001a28abef648b4597/html5/thumbnails/6.jpg)
Views3 Schema Architecture
PHYSICAL
CONCEPTUAL
LOGICALUser Views (Views or Queries)
Database administrators model for the data (E-R diagrams)
Actual data placement and structure (SQL statements)
![Page 7: Function](https://reader031.fdocuments.in/reader031/viewer/2022032420/55a4e3001a28abef648b4597/html5/thumbnails/7.jpg)
Security
Components that limit access or actions to limit potential damage
to data.
![Page 8: Function](https://reader031.fdocuments.in/reader031/viewer/2022032420/55a4e3001a28abef648b4597/html5/thumbnails/8.jpg)
Security
Limit data access to properly authorized users or programs. Protect data against accidental or intentional damage.
• Deter• Detect• Minimize• Recover• Investigate
![Page 9: Function](https://reader031.fdocuments.in/reader031/viewer/2022032420/55a4e3001a28abef648b4597/html5/thumbnails/9.jpg)
Security Approaches
� Views limit access and actions� Authorization Rules identify users and
restrict actions� User Defined Procedures in addition
to database security functions� Encryption encode stored data� Authentication positively identify users
![Page 10: Function](https://reader031.fdocuments.in/reader031/viewer/2022032420/55a4e3001a28abef648b4597/html5/thumbnails/10.jpg)
Authorization Rules
Subject Object Action Constraint
Sales Dept Cust Insert Credit < $5000
Program Ar4 Order Modify None
Terminal 12 Cust Modify Balance Due
Order Trans Cust Read None
![Page 11: Function](https://reader031.fdocuments.in/reader031/viewer/2022032420/55a4e3001a28abef648b4597/html5/thumbnails/11.jpg)
Authorization Rules
Some DBMS products authorize actions based on specific records and functional descriptions. However, most DBMS’s limit actions on tables to one of:• Read: view but not change• Insert: read and add records• Update: read, insert and change records
• Alter/Delete: read, insert, update and delete records, change table structure
![Page 12: Function](https://reader031.fdocuments.in/reader031/viewer/2022032420/55a4e3001a28abef648b4597/html5/thumbnails/12.jpg)
User Defined Procedures
Code modules that enforce security procedures are run during processing
UserProcedures
DBMSConstraints DBMS
![Page 13: Function](https://reader031.fdocuments.in/reader031/viewer/2022032420/55a4e3001a28abef648b4597/html5/thumbnails/13.jpg)
Integrity
Components that preserve the relationship among different
related records in the database
![Page 14: Function](https://reader031.fdocuments.in/reader031/viewer/2022032420/55a4e3001a28abef648b4597/html5/thumbnails/14.jpg)
Integrity
The relationship among records in the database
� Referential Integrity� Non Key Integrity� Derived Conditions
![Page 15: Function](https://reader031.fdocuments.in/reader031/viewer/2022032420/55a4e3001a28abef648b4597/html5/thumbnails/15.jpg)
Constraints in SQL
CREATE TABLE … or
ALTER TABLE … ADD� CHECK(condition)� PRIMARY KEY attribute-name� FOREIGN KEY attribute-name
REFERENCES parent-tableThe parent table must already have a primary key defined
![Page 16: Function](https://reader031.fdocuments.in/reader031/viewer/2022032420/55a4e3001a28abef648b4597/html5/thumbnails/16.jpg)
Concurrency
Preventing two users from interfering with each other when they use the same information
![Page 17: Function](https://reader031.fdocuments.in/reader031/viewer/2022032420/55a4e3001a28abef648b4597/html5/thumbnails/17.jpg)
Concurrency
� LockoutRestricting access to users who could be
misled by partial transactions
� VersioningMaking trial updates on versions of the
database and denying one if there is a data conflict.
![Page 18: Function](https://reader031.fdocuments.in/reader031/viewer/2022032420/55a4e3001a28abef648b4597/html5/thumbnails/18.jpg)
Locks
MasterStudent Grade
00 Fred01 Anthony02 Steve03 Ivan
Program 1 locks record<exclusive>.
No other program canread the record.No program can havean active lock.
Program 2 locks record<shared>
Other programs can read, but not changerecord.No program can have an exclusive lock.
![Page 19: Function](https://reader031.fdocuments.in/reader031/viewer/2022032420/55a4e3001a28abef648b4597/html5/thumbnails/19.jpg)
Locks
� On INSERT or UPDATE statements� SELECT column-names
FROM table-names
WHERE …
FOR UPDATE OF column-names
NOWAIT;
![Page 20: Function](https://reader031.fdocuments.in/reader031/viewer/2022032420/55a4e3001a28abef648b4597/html5/thumbnails/20.jpg)
ConcurrencyLocks
� Granularity
• Field
• Record
• Table
• Database
� Exclusivity
• Exclusive
• Shared
![Page 21: Function](https://reader031.fdocuments.in/reader031/viewer/2022032420/55a4e3001a28abef648b4597/html5/thumbnails/21.jpg)
ConcurrencyDeadlock
Two programs request conflicting sets of data lock up the database while awaiting access.• Program 1 locks record A
• Program 2 locks record B
• Program 1 requests lock on record B; waits• Program 2 requests lock on record A; waits
System either times out and restarts each transaction after a random wait or recognizes the deadlock to abort one program.
![Page 22: Function](https://reader031.fdocuments.in/reader031/viewer/2022032420/55a4e3001a28abef648b4597/html5/thumbnails/22.jpg)
Versioning
Version 1
Time 1 Version 2
Time 2Version 3
Time 3
Commits version 3 only after changes to versions 1 and 2 have been rolled back.
![Page 23: Function](https://reader031.fdocuments.in/reader031/viewer/2022032420/55a4e3001a28abef648b4597/html5/thumbnails/23.jpg)
Backup and Recovery
Processes to confirm and repeat transactions so that database
can be restored to a valid state after a problem.
![Page 24: Function](https://reader031.fdocuments.in/reader031/viewer/2022032420/55a4e3001a28abef648b4597/html5/thumbnails/24.jpg)
Backup and Recovery
� Backup Copies• Master• Transaction Log
� Journalization• Forward Log• Backward Log
� Checkpoints
![Page 25: Function](https://reader031.fdocuments.in/reader031/viewer/2022032420/55a4e3001a28abef648b4597/html5/thumbnails/25.jpg)
DBMS Logs
MasterStudent Grade
00 Fred01 Anthony02 Steve03 Ivan
TransactionInsert Li with grade AChange Fred’s grade to A
![Page 26: Function](https://reader031.fdocuments.in/reader031/viewer/2022032420/55a4e3001a28abef648b4597/html5/thumbnails/26.jpg)
Recover from Backup
� Slow� May give different answers from original
BackupTransac-
tion+ = RecoveredDatabase
![Page 27: Function](https://reader031.fdocuments.in/reader031/viewer/2022032420/55a4e3001a28abef648b4597/html5/thumbnails/27.jpg)
DBMS Logs
MasterStudent Grade
00 Fred A01 Anthony02 Steve03 Li A
TransactionIns Li with grade AChg Fred’s grade to A
Backward LogStudent Grade
03 n/p00 Fred
Forward LogStudent Grade
03 Li A00 Fred A
![Page 28: Function](https://reader031.fdocuments.in/reader031/viewer/2022032420/55a4e3001a28abef648b4597/html5/thumbnails/28.jpg)
DBMS Logs
MasterStudent Grade
00 Fred A01 Anthony02 Steve03 Li A
TransactionIns Li with grade AChg Fred’s grade to A10:00 Checkpoint
Backward LogStudent Grade
03 n/p00 Fred
Chkpt
Forward LogStudent Grade
03 Li A00 Fred A
Chkpt
![Page 29: Function](https://reader031.fdocuments.in/reader031/viewer/2022032420/55a4e3001a28abef648b4597/html5/thumbnails/29.jpg)
DBMS Logs
MasterStudent Grade
00 Fred A01 Anthony02 Steve B03 Li A
TransactionIns Li with grade AChg Fred’s grade to A10:00 CheckpointChg Steve grade to B
Backward LogStudent Grade
03 n/p00 Fred
Chkpt02 Steve
Forward LogStudent Grade
03 Li A00 Fred A
Chkpt02 Steve B
![Page 30: Function](https://reader031.fdocuments.in/reader031/viewer/2022032420/55a4e3001a28abef648b4597/html5/thumbnails/30.jpg)
Recover to Checkpoint Using Logs
ContaminatedDatabase
BackwardLog- Correct at
Checkpoint=
RecentTransactions+ Recovered
Database=
![Page 31: Function](https://reader031.fdocuments.in/reader031/viewer/2022032420/55a4e3001a28abef648b4597/html5/thumbnails/31.jpg)
Transaction Processing
A set of computer operations required to process a single unit of work.
A transaction must conclude with the database in a valid state whether the transaction terminates correctly or abnormally
![Page 32: Function](https://reader031.fdocuments.in/reader031/viewer/2022032420/55a4e3001a28abef648b4597/html5/thumbnails/32.jpg)
Transaction Processing
� Transaction Boundary• Locking
Exclusive Shared• Logging
Forward Backward Transaction
• Modification
Delete Insert Update• Commitment
Commit Rollback
![Page 33: Function](https://reader031.fdocuments.in/reader031/viewer/2022032420/55a4e3001a28abef648b4597/html5/thumbnails/33.jpg)
Transaction Boundaries
� Set Boundary• Obtain Locks• Execute Code Modules• Evaluate Correctness
� Commit or Rollback• Release Locks
![Page 34: Function](https://reader031.fdocuments.in/reader031/viewer/2022032420/55a4e3001a28abef648b4597/html5/thumbnails/34.jpg)
Transaction Boundaries
� Set savepoint:
SAVEPOINT order_save;� Commit or rollback:
ROLLBACK TO order_save;
![Page 35: Function](https://reader031.fdocuments.in/reader031/viewer/2022032420/55a4e3001a28abef648b4597/html5/thumbnails/35.jpg)
Transaction BoundariesPremiere Products Example
SALESREP CUSTOMER
ORDER-PRODUCT
ORDER
PRODUCT
Place an order for a new customer with a 1500 credit limit
![Page 36: Function](https://reader031.fdocuments.in/reader031/viewer/2022032420/55a4e3001a28abef648b4597/html5/thumbnails/36.jpg)
Transaction BoundariesPremiere Products Example
SALESREP CUSTOMER
ORDER-PRODUCT
ORDER
PRODUCT
•Insert CUSTOMER Record•Update CUSTOMER with SALESREP Foreign Key•Insert ORDER Record•Insert ORDER-PRODUCT with Foreign Keys•Update ProductOnHand in PRODUCT•Check Credit Limit
![Page 37: Function](https://reader031.fdocuments.in/reader031/viewer/2022032420/55a4e3001a28abef648b4597/html5/thumbnails/37.jpg)
Transaction ProcessingProgramming Logic
Two phased locking requires obtaining locks on all necessary records before releasing locks on any records.
� Obtain locks on all records needed� Perform calculations� Release locks
![Page 38: Function](https://reader031.fdocuments.in/reader031/viewer/2022032420/55a4e3001a28abef648b4597/html5/thumbnails/38.jpg)
Functions of a DBMSC.J. Date
� Indexing� Views� Security� Integrity� Concurrency
� Backup/Recovery� Design� Documentation� Update/Query