Database: A collection of related data [Elmasri]. • A database represents some aspect of real world called “miniworld” [Elmasri] or “enterprise”[Ramakrishnan]. • A database can be of any size and of varying complexity. • It may be generated and maintained manually or using computers. A few fundamental questions • • • • What data to store? How to describe this data? How to store this data? How to retrieve information from the data? Data Models • A data model is a collection of concepts for describing data. • A schema is a description of a particular collection of data, using a given data model. View 1 The three-schema architecture View 2 View 3 Conceptual Schema Physical Schema External Schema Conceptual Schema Internal Schema Example of Schemas in Relational Data Model • Conceptual schema: – – – Students (sid: string, name: string, login: string, age: integer, gpa:real) Courses (cid: string, cname:string, credits:integer) Enrolled (sid:string, cid:string, grade:string) • Physical schema: – – Relations stored as unordered files, heap files, or hashed files. Index on first column of Students. Tree-based indexes or hash-based indexes can be used. • External Schema (View): – Course_info(cid:string,enrollment:integer) Classification of Databases By data model • Network Databases (early 1960s); E.g., IDS, IDMS • Hierarchical Databases (e.g., SABRE); E.g., IBM’s IMS • Relational (1970) Databases (RDBMS); widely used • Object-oriented Databases (OODBMS); E.g., ObjectStore, Poet. • Object-relational Databases (ORDBMS); • • • • • • • Deductive Databases Active Databases Real-time Databases Spatial Databases Temporal Databases Multimedia Databases Parallel and Distributed Databases Database Management System (DBMS): A software package designed to store and manage databases. Relational DBMSs: DB2, Informix, Oracle, Sybase, Microsoft Access, Microsoft SQL Server, FoxBase, Paradox, Teradata, MySQL, mSQL, etc. Advantage of DBMS: Data Independence • Applications insulated from how data is structured and stored • DBMS provides an abstract view, without exposing data representation and storage • DBMS also allow users to manipulate the data in a convenient way A1 P1 OS vs. DMBS read/write OS 1) 2) Data unit (file vs table) Data manipulation read/write DBMS .... 1100101010… : : Advantages of DBMS: Efficient Access • Use indexes – Sophisticate techniques are used to ensure efficient store and retrieval of massive data • Query optimization – rewrites query for a better response time using statistics maintained in the database management system • Support extremely large databases – Beyond the limitation of the underlying OS Advantages of DBMS: Reduce Application Development Time • Do not need to write the database management software for each application • Use standard query languages to access data such as SQL • Use standard ways to write database applications – – – – – JDBC for Java language ODBC Perl DBI PHP ProC Advantages of DBMS: Security & Integrity • Secrecy: Users should not be able to see things they are not supposed to. – E.g., A student can’t see other students’ grades. • Integrity: Users should not be able to modify things they are not supposed to. – E.g., Only instructors can assign grades. • Availability: Users should be able to see and modify things they are allowed to. Advantages of DBMS: Concurrency Control • Concurrent execution of user programs is essential for good DBMS performance. – Because disk accesses are frequent, and relatively slow, it is important to keep CPU working on several user programs concurrently. • Interleaving actions of different user programs can lead to inconsistency. • DBMS ensures such problems don’t arise: users can pretend they are using a single-user system. Structure of a DBMS • A typical DBMS has a layered architecture. • The figure does not show the concurrency control and recovery components. • This is one of several possible architectures; each system has its own variations. These layers must consider concurrency control and recovery Query Optimization and Execution Relational Operators Files and Access Methods Buffer Management Disk Space Management DB Career Choices in Database Areas • • • • • • • • • • System analysts Project managers Database administrators Database application developers/testers Customer supports Consultants DBMS developers Database Researchers Database book authors Database software instructors