Presentation on theme: "Database Management Systems (ECS-402)"— Presentation transcript:
1Database Management Systems (ECS-402) UNIT 1INTRODUCTION TO DBMSRohit Khokher
2Objectives What is a database? How are databases used to build applications?What are the major components of a database management system?What are the advantages of using a database management system?What are the main database management systems?How have database management systems changed over time?What are the first steps to start a project?
3Syllabus An overview of database management system Database system Vs file systemDatabase system concept and architectureData model schema and instancesData independence and database language and interfacesData definitions language, DMLOverall Database Structure.Data Modeling using the Entity Relationship ModelER model concepts, notation for ER diagram, mapping constraints, keysConcepts of Super Key, candidate key, primary keyGeneralization, AggregationReduction of an ER diagrams to tables, extended ER model, relationship of higher degree.
4Stages of Information System Stage 0: Manual Information SystemRecordsFilesIndex CardsStage 1: Sequential Information SystemsTapesslow, non-interactive, redundancy,... .Stage 2: File Based Information SystemsDisk (direct access)application program has its own file data dependencedata redundancyStage 3: DBMS based Information SystemsGeneralized data management softwareTransaction processing
5What is a Database System? ApplicationprogramEnd-userDBMS
6What is a Database System? (cont.) Major components of a database system:Data: integrated and shared.Hardware: disk, CPU, Main Memory, ...Software: DBMSUsers:1. Application programmers2. End users3. Database administrator (DBA)Defining external schemaDefining conceptual schemaDefining internal schemaLiaison with usersDefining security and integrity checksDefining backup and recovery proceduresMonitoring performance and changing requirements
7Why Database ? Redundancy can be reduced Inconsistency can be avoided The data can be sharedStandards can be enforcedSecurity restrictions can be appliedIntegrity can be maintainedProvision of data independenceobjective !
8Data Independence Application Program Data Structure Immunity of application to change in storage structure and access strategy.
9Functions of the DBMS Data Definition Language (DDL) Data Manipulation Language (DML)Data Security and IntegrityData Recovery and ConcurrencyData DictionaryPerformance
11Database Management System (DBMS) DBMS contains information about a particular enterpriseCollection of interrelated dataSet of programs to access the dataAn environment that is both convenient and efficient to useDatabase Applications:Banking: all transactionsAirlines: reservations, schedulesUniversities: registration, gradesSales: customers, products, purchasesOnline retailers: order tracking, customized recommendationsManufacturing: production, inventory, orders, supply chainHuman resources: employee records, salaries, tax deductionsDatabases touch all aspects of our lives
12Purpose of Database Systems In the early days, database applications were built directly on top of file systemsDrawbacks of using file systems to store data:Data redundancy and inconsistencyMultiple file formats, duplication of information in different filesDifficulty in accessing dataNeed to write a new program to carry out each new taskData isolation — multiple files and formatsIntegrity problemsIntegrity constraints (e.g. account balance > 0) become “buried” in program code rather than being stated explicitlyHard to add new constraints or change existing ones
13Purpose of Database Systems (Cont.) Drawbacks of using file systems (cont.)Atomicity of updatesFailures may leave database in an inconsistent state with partial updates carried outExample: Transfer of funds from one account to another should either complete or not happen at allConcurrent access by multiple usersConcurrent accessed needed for performanceUncontrolled concurrent accesses can lead to inconsistenciesExample: Two people reading a balance and updating it at the same timeSecurity problemsHard to provide user access to some, but not all, dataDatabase systems offer solutions to all the above problems
14An architecture for a database system View of DataAn architecture for a database system
15Levels of AbstractionPhysical level: describes how a record (e.g., customer) is stored.Logical level: describes data stored in database, and the relationships among the data.type customer = recordcustomer_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.
16Instances and SchemasSimilar to types and variables in programming languagesSchema – the logical structure of the databaseExample: 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 programPhysical schema: database design at the physical levelLogical schema: database design at the logical levelInstance – the actual content of the database at a particular point in timeAnalogous to the value of a variablePhysical Data Independence – the ability to modify the physical schema without changing the logical schemaApplications depend on the logical schemaIn general, the interfaces between the various levels and components should be well defined so that changes in some parts do not seriously influence others.
17Data Models A collection of tools for describing Data Data relationshipsData semanticsData constraintsRelational modelEntity-Relationship data model (mainly for database design)Object-based data models (Object-oriented and Object-relational)Semistructured data model (XML)Other older models:Network modelHierarchical model
18Data Manipulation Language (DML) Language for accessing and manipulating the data organized by the appropriate data modelDML also known as query languageTwo classes of languagesProcedural – user specifies what data is required and how to get those dataDeclarative (nonprocedural) – user specifies what data is required without specifying how to get those dataSQL is the most widely used query language
19Data Definition Language (DDL) Specification notation for defining the database schemaExample: create table account ( account_number char(10),branch_name char(10),balance integer)DDL compiler generates a set of tables stored in a data dictionaryData dictionary contains metadata (i.e., data about data)Database schemaData storage and definition languageSpecifies the storage structure and access methods usedIntegrity constraintsDomain constraintsReferential integrity (e.g. branch_name must correspond to a valid branch in the branch table)Authorization
20Relational Model Example of tabular data in the relational model Attributes
22SQL SQL: widely used non-procedural language Example: Find the name of the customer with customer-id select customer.customer_name from customer where customer.customer_id = ‘ ’Example: Find the balances of all accounts held by the customer with customer-id select account.balance from depositor, account where depositor.customer_id = ‘ ’ and depositor.account_number = account.account_numberApplication programs generally access databases through one ofLanguage extensions to allow embedded SQLApplication program interface (e.g., ODBC/JDBC) which allow SQL queries to be sent to a database
23Database DesignThe process of designing the general structure of the database:Logical Design – Deciding on the database schema. Database design requires that we find a “good” collection of relation schemas.Business decision – What attributes should we record in the database?Computer Science decision – What relation schemas should we have and how should the attributes be distributed among the various relation schemas?Physical Design – Deciding on the physical layout of the database
24The Entity-Relationship Model Models an enterprise as a collection of entities and relationshipsEntity: a “thing” or “object” in the enterprise that is distinguishable from other objectsDescribed by a set of attributesRelationship: an association among several entitiesRepresented diagrammatically by an entity-relationship diagram:
25Other Data Models Object-oriented data model Object-relational data model
27Database Management System Internals Storage managementQuery processingTransaction processing
28Storage ManagementStorage manager is a program module that provides the interface between the low-level data stored in the database and the application programs and queries submitted to the system.The storage manager is responsible to the following tasks:Interaction with the file managerEfficient storing, retrieving and updating of dataIssues:Storage accessFile organizationIndexing and hashing
29Query Processing 1. Parsing and translation 2. Optimization 3. Evaluation
30Query Processing (Cont.) Alternative ways of evaluating a given queryEquivalent expressionsDifferent algorithms for each operationCost difference between a good and a bad way of evaluating a query can be enormousNeed to estimate the cost of operationsDepends critically on statistical information about relations which the database must maintainNeed to estimate statistics for intermediate results to compute cost of complex expressions
31Transaction Management A transaction is a collection of operations that performs a single logical function in a database applicationTransaction-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.
34Advantages of Database Approach Minimal data redundancy.Data consistency.Integration of data.Sharing of data.Enforcement of standards.Ease of application development.Uniform security, privacy and integrity.Data independence.Advantages of a DBMS. The DBMS provides a solution to basic data storage and retrieval problems. By using a DBMS to handle data storage problems, programmers can concentrate on building applications—saving time and money in developing new systems and simplifying maintenance of existing applications.
35Drawbacks of old File methods Uncontrolled DuplicationWastes spaceHard to update all filesInconsistent dataInflexibilityHard to change dataHard to change programsLimited data sharingPoor enforcement of standardsPoor programmer productivityExcessive program maintenance
36File Method Problems Files defined in program Multiuser problems Cannot read file without definitionHard to find definitionEvery time you alter file, you must rewrite codeChange in a program/file will crash other codeCannot tell which programs use each fileMultiuser problemsConcurrencySecurityAccessBackup & RestoreEfficiencyIndexesProgrammer talentSystemApplication
37Examples of Commercial Systems VendorProductOracleMicrosoftSQL ServerAccessIBMDB2InformixOpen sourcePostgreSQLMySQL ABMySQLCommercial DBMS vendors. These are the leading DBMS products that you are likely to encounter. Many older systems exist, and dozens of smaller vendors provide complete systems and other tools.
38How do you sell a DBMS approach? Applications change a lot, but same data.Need for ad hoc questions and queries.Need to reduce development times.Need shared data.Improve quality of data.Enable users to do more development.