Introductionمقدمة
مقدمة الفصل
ماذا ستتعلم في هذا الفصل
- The Need for Databases
- Data Models
- Relational Databases
- Database Design
- Storage Manager
- Query Processing
- Transaction Manager
أقسام الفصل
- 1Database management systems and the drawbacks of file systemsنظم إدارة قواعد البيانات وعيوب أنظمة الملفات
- 2Levels of abstraction, schemas, instances and data independenceمستويات التجريد والمخططات والنسخ واستقلال البيانات
- 3Data modelsنماذج البيانات
- 4DDL, DML and SQLلغة تعريف البيانات ولغة معالجتها وSQL
- 5Database designتصميم قواعد البيانات
- 6The database engine: storage, query processing, transactionsمحرك قاعدة البيانات: التخزين والاستعلام والمعاملات
- 7Database users and database architectureمستخدمو قاعدة البيانات وبنيتها
تلميح: استخدم أسهم لوحة المفاتيح للتنقل بين الشرائح.
Database Management System (DBMS)نظام إدارة قواعد البيانات
Database management systems and the drawbacks of file systems
Contains information about a particular enterprise: a collection of interrelated data, a set of programs to access the data, and an environment that is both convenient and efficient to use.
Database applications (slide 3)
- Banking: transactions
- Airlines: reservations, schedules
- Universities: registration, grades
- Sales: customers, products, purchases
- Online retailers: order tracking, recommendations
- Manufacturing: production, inventory, supply chain
- Human resources: employee records, salaries
- University database example: add students, instructors, courses; register students and generate class rosters; assign grades, compute GPA and generate transcripts.
- In the early days, database applications were built directly on top of file systems.
Drawbacks of using file systems to store dataعيوب أنظمة الملفات
Database management systems and the drawbacks of file systems
| Drawback (slides 5–6) | What goes wrong |
|---|---|
| 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 |
|
| Atomicity of updates | Failures may leave the database inconsistent with partial updates |
| Concurrent access by multiple users | Uncontrolled concurrent accesses can lead to inconsistencies |
| Security problems | Hard to provide user access to some, but not all, data |
- Database systems offer solutions to all the above problems.
Levels of abstractionمستويات التجريد
view level
Describes how a record (e.g., instructor) is stored.
Describes data stored in database, and the relationships among the data (e.g., type instructor = record ID, name, dept_name, salary).
Application programs hide details of data types; views can also hide information (such as an employee's salary) for security purposes.
- In the figure, the view level sits on the logical level, which sits on the physical level.
Schemas and instancesالمخطط والنسخة
Levels of abstraction, schemas, instances and data independence
Structural design that defines how data is organized, stored, and related. The process of designing a schema is known as data modeling.
| Schema | Defines (slide 9) |
|---|---|
| Physical schema | How data is physically stored on disk or storage devices: file structures, indices, partitioning, compression |
| Logical schema | What data is stored and the overall logical structure: tables, attributes, primary keys, foreign keys, integrity constraints — without worrying about physical storage |
| View schema | Highest level of abstraction: how end-users interact with the database, a view as per the user role of application |
The actual content of the database at a particular point in time — analogous to the value of a variable.
Data independenceاستقلال البيانات
Ability to modify the database schema at one level of a database system without affecting the schema at the next higher level.
Physical data independenceالاستقلال المادي
- Modify the physical schema without changing the logical schema
- Applications depend on the logical schema
- Example: switching from a Hard Disk to a Solid State Drive (SSD)
Logical data independenceالاستقلال المنطقي
- Modify the conceptual schema without modifying view/external schema
- Example: adding a new column (attribute) to a table or modifying an entity relationship
Data modelsنماذج البيانات
A collection of tools for describing data, data relationships, data semantics, data constraints.
- Relational modelAll the data is stored in various tables (columns and rows).
- Entity-Relationship data modelMainly for database design.
- Object-based data modelsObject-oriented and object-relational.
- Semistructured data modelXML.
- Other older modelsNetwork model; hierarchical model.
Object-relational data models and XMLالكائني العلائقي وXML
Object-relational data models (slide 20)
- Relational model: flat, "atomic" values.
- Extend the relational data model by including object orientation and constructs to deal with added data types.
- Allow attributes of tuples to have complex types, including non-atomic values such as nested relations.
- Preserve relational foundations, in particular the declarative access to data, while extending modeling power.
- Provide upward compatibility with existing relational languages.
XML: Extensible Markup Language (slide 21)
- Defined by the WWW Consortium (W3C).
- Originally intended as a document markup language, not a database language.
- New tags and nested tag structures made XML a great way to exchange data, not just documents.
- XML has become the basis for all new generation data interchange formats.
Data Definition Language (DDL)لغة تعريف البيانات
DDL, DML and SQL
Specification notation for defining the database schema.
- DDL compiler generates a set of table templates stored in a data dictionary.
- Data dictionary contains metadata (i.e., data about data):
- Database schema
- Integrity constraints — primary key (ID uniquely identifies instructors)
- Authorization — who can access what
DML and SQLDML و SQL
Language for accessing and manipulating the data organized by the appropriate data model; also known as query language.
Pure
- Used for proving properties about computational power and for optimization
- Relational Algebra
- Tuple relational calculus
- Domain relational calculus
Commercial
- Used in commercial systems
- SQL is the most widely used commercial language
- SQL is NOT a Turing machine equivalent language; to compute complex functions SQL is usually embedded in some higher-level language.
- Application programs access databases through language extensions to allow embedded SQL or an application program interface (e.g., ODBC/JDBC).
Database designتصميم قاعدة البيانات
Logical designالتصميم المنطقي
- Deciding on the database schema
- Find a "good" collection of relation schemas
- Business decision: what attributes should we record?
- Computer Science decision: what relation schemas, and how are attributes distributed among them?
Physical designالتصميم المادي
- Deciding on the physical layout of the database
Slide 18
One relation holds ID, name, salary, dept_name, building, budget for every instructor. "Is there any problem with this relation?"
The slide does not print an answer. In its table the department's building and budget repeat for every instructor of that department (Comp. Sci., Taylor, 100000 appears three times) — the kind of duplication slide 5 calls data redundancy.
Entity Relationship Model
- Models an enterprise as a collection of entities and relationships
- Represented by an entity-relationship diagram
Normalization Theory
- Formalize what designs are bad, and test for them
Database engine and storage managementالمحرك ومدير التخزين
The database engine: storage, query processing, transactions
Database engine (slide 22)
- Storage manager
- Query processor
- Transaction manager
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.
- Responsible for: interaction with the OS file manager; efficient storing, retrieving and updating of data.
- Issues: storage access; file organization; indexing and hashing.
Query processingمعالجة الاستعلامات
- 1
Parsing and translation
- 2
Optimization
- 3
Evaluation
- Alternative ways of evaluating a query: equivalent expressions; different algorithms for each operation.
- Cost difference between a good and a bad way of evaluating a query can be enormous.
- Estimating the cost of operations depends critically on statistical information about relations which the database must maintain; statistics for intermediate results are also estimated.
Transaction managementإدارة المعاملات
The database engine: storage, query processing, transactions
A collection of operations that performs a single logical function in a database application.
Ensures that the database remains in a consistent (correct) state despite system failures (e.g., power failures and operating system crashes) and transaction failures.
Controls the interaction among the concurrent transactions, to ensure the consistency of the database.
Database users and architectureالمستخدمون والبنية
Database users and database architecture
| User (slide 27) | Interacts through |
|---|---|
| Naive users (tellers, agents, web users) | use application interfaces |
| Application programmers | write application programs |
| Sophisticated users (analysts) | use query tools |
| Database administrators | use administration tools |
Database architecture (slide 29)
- Centralized
- Client-server
- Parallel (multi-processor)
- Distributed
- The architecture is greatly influenced by the underlying computer system on which the database is running.
الخلاصة
أنهيت الدرس
الخطوة التالية: ثبّت المعلومات بالبطاقات، ثم اختبر نفسك بالأسئلة.
ما راجعته في هذا الدرس
- Database management systems and the drawbacks of file systemsنظم إدارة قواعد البيانات وعيوب أنظمة الملفات
- Levels of abstraction, schemas, instances and data independenceمستويات التجريد والمخططات والنسخ واستقلال البيانات
- Data modelsنماذج البيانات
- DDL, DML and SQLلغة تعريف البيانات ولغة معالجتها وSQL
- Database designتصميم قواعد البيانات
- The database engine: storage, query processing, transactionsمحرك قاعدة البيانات: التخزين والاستعلام والمعاملات
- Database users and database architectureمستخدمو قاعدة البيانات وبنيتها