1 / 46

DATABASE MANAGEMENT SYSTEMS

DATABASE MANAGEMENT SYSTEMS. Contents. Introduction to DBMS DBMS Users DBMS architecture Data Models ER Modeling Relational Model SQL Normalization. What Is a DBMS?. Database : A very large, integrated collection of data.

crystalh
Download Presentation

DATABASE MANAGEMENT SYSTEMS

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. www.BookSpar.com | Website for Students | VTU NOTES -QUESTION PAPERS DATABASE MANAGEMENT SYSTEMS

  2. www.BookSpar.com | Website for Students | VTU NOTES -QUESTION PAPERS Contents • Introduction to DBMS • DBMS Users • DBMS architecture • Data Models • ER Modeling • Relational Model • SQL • Normalization

  3. www.BookSpar.com | Website for Students | VTU NOTES -QUESTION PAPERS What Is a DBMS? • Database : A very large, integrated collection of data. • A DatabaseManagementSystem(DBMS)is a software package designed to store and manage databases.

  4. www.BookSpar.com | Website for Students | VTU NOTES -QUESTION PAPERS Database System Applications • Database Applications: • Banking: all transactions • Airlines: reservations, schedules • Universities: registration, grades • Sales: customers, products, purchases • Online retailers: order tracking, customized recommendations • Manufacturing: production, inventory, orders, supply chain • Human resources: employee records, salaries, tax deductions • Databases touch all aspects of our lives

  5. www.BookSpar.com | Website for Students | VTU NOTES -QUESTION PAPERS

  6. www.BookSpar.com | Website for Students | VTU NOTES -QUESTION PAPERS

  7. www.BookSpar.com | Website for Students | VTU NOTES -QUESTION PAPERS

  8. www.BookSpar.com | Website for Students | VTU NOTES -QUESTION PAPERS

  9. www.BookSpar.com | Website for Students | VTU NOTES -QUESTION PAPERS

  10. www.BookSpar.com | Website for Students | VTU NOTES -QUESTION PAPERS Purpose of Database Systems • In the early days, database applications were built directly on top of file systems • Drawbacks of using file systems to store data: • Data redundancy and inconsistency • Multiple file formats, duplication of information in different files • Difficulty in accessing data • Need to write a new program to carry out each new task • Data isolation — multiple files and formats • Integrity problems • Integrity constraints (e.g. account balance > 0) become “buried” in program code rather than being stated explicitly • Hard to add new constraints or change existing ones

  11. www.BookSpar.com | Website for Students | VTU NOTES -QUESTION PAPERS Purpose of Database Systems (Cont.) • Drawbacks of using file systems (cont.) • Atomicity of updates • Failures may leave database in an inconsistent state with partial updates carried out • Example: Transfer of funds from one account to another should either complete or not happen at all • Concurrent access by multiple users • Concurrent accessed needed for performance • Uncontrolled concurrent accesses can lead to inconsistencies • Example: Two people reading a balance and updating it at the same time • Security problems • Hard to provide user access to some, but not all, data • Database systems offer solutions to all the above problems

  12. www.BookSpar.com | Website for Students | VTU NOTES -QUESTION PAPERS Why Use a DBMS? • Data independence and efficient access. • Reduced application development time. • Data integrity and security. • Uniform data administration. • Concurrent access, recovery from crashes.

  13. www.BookSpar.com | Website for Students | VTU NOTES -QUESTION PAPERS Database Users Users are differentiated by the way they expect to interact with the system • Application programmers – interact with system through DML calls • Sophisticated users – form requests in a database query language • Naïve users – invoke one of the permanent application programs that have been written previously • Examples, people accessing database over the web, bank tellers, clerical staff

  14. www.BookSpar.com | Website for Students | VTU NOTES -QUESTION PAPERS Database Administrator • Coordinates all the activities of the database system • has a good understanding of the enterprise’s information resources and needs. • Database administrator's duties include: • Storage structure and access method definition • Schema and physical organization modification • Granting users authority to access the database • Backing up data • Monitoring performance and responding to changes

  15. www.BookSpar.com | Website for Students | VTU NOTES -QUESTION PAPERS View of Data An architecture for a database system

  16. www.BookSpar.com | Website for Students | VTU NOTES -QUESTION PAPERS Levels of Abstraction • Physical level: describes how a record (e.g., customer) is stored. • Logical level: describes data stored in database, and the relationships among the data. typecustomer = record customer_id : string; customer_name : string;customer_street : string;customer_city : string; end; • View level: application programs hide details of data types. Views can also hide information (such as an employee’s salary) for security purposes.

  17. www.BookSpar.com | Website for Students | VTU NOTES -QUESTION PAPERS Instances and Schemas • Similar to types and variables in programming languages • Schema – the logical structure of the database • Example: The database consists of information about a set of customers and accounts and the relationship between them) • Analogous to type information of a variable in a program • Physical schema: database design at the physical level • Logical schema: database design at the logical level

  18. www.BookSpar.com | Website for Students | VTU NOTES -QUESTION PAPERS Instances and Schemas • Physical Data Independence – the ability to modify the physical schema without changing the logical schema • Applications depend on the logical schema • In general, the interfaces between the various levels and components should be well defined so that changes in some parts do not seriously influence others.

  19. www.BookSpar.com | Website for Students | VTU NOTES -QUESTION PAPERS Data Independence • Applications insulated from how data is structured and stored. • Logical data independence:Protection from changes in logical structure of data. • Physicaldata independence:Protection from changes in physical structure of data. • One of the most important benefits of using a DBMS!

  20. www.BookSpar.com | Website for Students | VTU NOTES -QUESTION PAPERS History of Database Systems • 1950s and early 1960s: • Data processing using magnetic tapes for storage • Tapes provide only sequential access • Punched cards for input • Late 1960s and 1970s: • Hard disks allow direct access to data • Network and hierarchical data models in widespread use • Ted Codd defines the relational data model • Would win the ACM Turing Award for this work • IBM Research begins System R prototype • UC Berkeley begins Ingres prototype • High-performance (for the era) transaction processing

  21. www.BookSpar.com | Website for Students | VTU NOTES -QUESTION PAPERS History (cont.) • 1980s: • Research relational prototypes evolve into commercial systems • SQL becomes industry standard • Parallel and distributed database systems • Object-oriented database systems • 1990s: • Large decision support and data-mining applications • Large multi-terabyte data warehouses • Emergence of Web commerce • 2000s: • XML and XQuery standards • Automated database administration • Increasing use of highly parallel database systems • Web-scale distributed data storage systems

  22. www.BookSpar.com | Website for Students | VTU NOTES -QUESTION PAPERS Data Models • A datamodelis a collection of concepts for describing data. • Relational model • Entity-Relationship data model (mainly for database design) • Object-based data models (Object-oriented and Object-relational) • Semi structured data model (XML) • Other older models: • Network model • Hierarchical model • The relational model of datais the most widely used model today.

  23. www.BookSpar.com | Website for Students | VTU NOTES -QUESTION PAPERS Database Design- Conceptual design:(ER Model) • A database can be modeled as: • a collection of entities, • relationship among entities. • An entityis an object that exists and is distinguishable from other objects. • Example: specific person, company, event, plant • Entities have attributes • Example: people have names and addresses • An entity set is a set of entities of the same type that share the same properties. • Example: set of all persons, companies, trees, holidays • Relationship:Association among two or more entities. E.g., Aisha works in Pharmacy department

  24. name ssn lot Employees Policies policyid cost www.BookSpar.com | Website for Students | VTU NOTES -QUESTION PAPERS ER-diagram pname age Dependents Covers

  25. www.BookSpar.com | Website for Students | VTU NOTES -QUESTION PAPERS Relational Model Attributes • Example of tabular data in the relational model

  26. www.BookSpar.com | Website for Students | VTU NOTES -QUESTION PAPERS A Sample Relational Database

  27. name ssn lot Employees www.BookSpar.com | Website for Students | VTU NOTES -QUESTION PAPERS Logical DB Design: ER to Relational • Entity sets to tables: SSN Name lot

  28. www.BookSpar.com | Website for Students | VTU NOTES -QUESTION PAPERS INTRODUCTION TO SCHEMA REFINEMENT Problems Caused by Redundancy • Storing the same information redundantly, that is, in more than one place within a database, can lead to several problems: • Redundant storage: Some information is stored repeatedly. • Update anomalies: If one copy of such repeated data is updated, an inconsistency is created unless all copies are similarly updated. • Insertion anomalies: It may not be possible to store some information unless some other information is stored as well. • Deletion anomalies: It may not be possible to delete some information

  29. www.BookSpar.com | Website for Students | VTU NOTES -QUESTION PAPERS Bad DB Design to good DB Design • Informal method • Informal design guidelines • Formal method - Normalization

  30. www.BookSpar.com | Website for Students | VTU NOTES -QUESTION PAPERS Normal Forms • If a relation is in a certain normal form (BCNF, 3NFetc.), it is known that certain kinds of problems are avoided/minimized. This can be used to help us decide whether decomposing the relation will help. • FDs are used to detect redundancy

  31. www.BookSpar.com | Website for Students | VTU NOTES -QUESTION PAPERS Example decomposition(simple) • Bad database design • Good database design Eno Ename Salary Add Bdate Dno Dname Mngname Eno Ename Salary Add Bdate Dno Dno Dname Mngname

  32. www.BookSpar.com | Website for Students | VTU NOTES -QUESTION PAPERS Data Definition Language (DDL) • Specification notation for defining the database schema Example: create tableaccount (account_numberchar(10), branch_name char(10), balanceinteger) • DDL compiler generates a set of tables stored in a data dictionary • Data dictionary contains metadata (i.e., data about data) • Database schema • Data storage and definition language • Specifies the storage structure and access methods used • Integrity constraints • Domain constraints • Referential integrity (e.g. branch_name must correspond to a valid branch in the branch table) • Authorization

  33. www.BookSpar.com | Website for Students | VTU NOTES -QUESTION PAPERS Data Manipulation Language (DML) • Two classes of languages • Procedural – user specifies what data is required and how to get those data • Declarative (nonprocedural) – user specifies what data is required without specifying how to get those data • SQL is the most widely used query language

  34. www.BookSpar.com | Website for Students | VTU NOTES -QUESTION PAPERS SQL • SQL: widely used non-procedural language • Example: Find the name of the customer with customer-id 192select customer_namefrom customerwherecustomer_id = 192 • Example: Find the balances of all accounts held by the customer with customer-id 192 selectbalancefrom depositor, accountwherecustomer_id = 192 and depositor.account_number = account.account_number

  35. www.BookSpar.com | Website for Students | VTU NOTES -QUESTION PAPERS SQL • Application programs generally access databases through one of • Language extensions to allow embedded SQL • Application program interface (e.g., ODBC/JDBC) which allow SQL queries to be sent to a database

  36. www.BookSpar.com | Website for Students | VTU NOTES -QUESTION PAPERS Query Processing 1.Parsing and translation 2. Optimization 3. Evaluation

  37. www.BookSpar.com | Website for Students | VTU NOTES -QUESTION PAPERS Query Processing (Cont.) • Alternative ways of evaluating a given query • Equivalent expressions • Different algorithms for each operation • Cost difference between a good and a bad way of evaluating a query can be enormous • Need to estimate the cost of operations • Depends critically on statistical information about relations which the database must maintain • Need to estimate statistics for intermediate results to compute cost of complex expressions

  38. www.BookSpar.com | Website for Students | VTU NOTES -QUESTION PAPERS Transaction Management • A transaction is a collection of operations that performs a single logical function in a database application • Transaction-management component ensures that the database remains in a consistent (correct) state despite system failures (e.g., power failures and operating system crashes) and transaction failures. • Concurrency-control manager controls the interaction among the concurrent transactions, to ensure the consistency of the database.

  39. www.BookSpar.com | Website for Students | VTU NOTES -QUESTION PAPERS Transaction Concept • A transactionis a unit of program execution that accesses and possibly updates various data items. • E.g. transaction to transfer $50 from account A to account B: 1. read(A) 2. A := A – 50 3. write(A) 4. read(B) 5. B := B + 50 6. write(B) • Two main issues to deal with: • Failures of various kinds, such as hardware failures and system crashes • Concurrent execution of multiple transactions

  40. www.BookSpar.com | Website for Students | VTU NOTES -QUESTION PAPERS Example of Fund Transfer • Transaction to transfer $50 from account A to account B: 1. read(A) 2. A := A – 50 3. write(A) 4. read(B) 5. B := B + 50 6. write(B) • Atomicity requirement • if the transaction fails after step 3 and before step 6, money will be “lost” leading to an inconsistent database state • Failure could be due to software or hardware • the system should ensure that updates of a partially executed transaction are not reflected in the database • Durability requirement — once the user has been notified that the transaction has completed (i.e., the transfer of the $50 has taken place), the updates to the database by the transaction must persist even if there are software or hardware failures.

  41. www.BookSpar.com | Website for Students | VTU NOTES -QUESTION PAPERS Example of Fund Transfer (contd..) • Transaction to transfer $50 from account A to account B: 1. read(A) 2. A := A – 50 3. write(A) 4. read(B) 5. B := B + 50 6. write(B) • Consistency requirement in above example: • the sum of A and B is unchanged by the execution of the transaction • A transaction must see a consistent database. • During transaction execution the database may be temporarily inconsistent. • When the transaction completes successfully the database must be consistent • Erroneous transaction logic can lead to inconsistency

  42. www.BookSpar.com | Website for Students | VTU NOTES -QUESTION PAPERS Example of Fund Transfer (Cont.) • Isolation requirement — if between steps 3 and 6, another transaction T2 is allowed to access the partially updated database, it will see an inconsistent database (the sum A + B will be less than it should be).T1 T2 1. read(A) 2. A := A – 50 3. write(A) read(A), read(B), print(A+B) 4. read(B) 5. B := B + 50 6. write(B • Isolation can be ensured trivially by running transactions serially • that is, one after the other. • However, executing multiple transactions concurrently has significant benefits.

  43. www.BookSpar.com | Website for Students | VTU NOTES -QUESTION PAPERS ACID Properties A transaction is a unit of program execution that accesses and possibly updates various data items.To preserve the integrity of data the database system must ensure: • Atomicity. Either all operations of the transaction are properly reflected in the database or none are. • Consistency. Execution of a transaction in isolation preserves the consistency of the database. • Isolation. Although multiple transactions may execute concurrently, each transaction must be unaware of other concurrently executing transactions. Intermediate transaction results must be hidden from other concurrently executed transactions. • That is, for every pair of transactions Tiand Tj, it appears to Tithat either Tj, finished execution before Ti started, or Tj started execution after Ti finished. • Durability. After a transaction completes successfully, the changes it has made to the database persist, even if there are system failures.

  44. www.BookSpar.com | Website for Students | VTU NOTES -QUESTION PAPERS Transaction State

  45. www.BookSpar.com | Website for Students | VTU NOTES -QUESTION PAPERS Concurrent Executions • Multiple transactions are allowed to run concurrently in the system. Advantages are: • increased processor and disk utilization, leading to better transaction throughput • E.g. one transaction can be using the CPU while another is reading from or writing to the disk • reduced average response time for transactions: short transactions need not wait behind long ones. • Concurrency control schemes– mechanisms to achieve ACID properties with concurrency. • Concurrency control protocols are used in DBMSs to control concurrency

  46. www.BookSpar.com | Website for Students | VTU NOTES -QUESTION PAPERS Overall System Structure

More Related