Download Database Fundamentals & DBMS Concepts and more Exams Engineering in PDF only on Docsity!
D A T A B A S E S Y S T E M S
Database Fundamentals & DBMS
Concepts
Complete Exam Revision Notes with Worked Examples and Practice Questions
Part 1 of the Database Systems Revision Series
Covers: DBMS basics, file systems vs DBMS, three-schema architecture, data models, database
languages, DBMS architecture, database life cycle
Includes: 15 practice questions with full answers, glossary, one-page revision summary
What This Guide Covers
Use this page as a map of the unit. Each section ends with the points examiners ask about most
often.
# Section Why it matters in exams 1 Introduction: data, information, database, DBMS Definitions are asked almost every year 2 File-based systems vs the database approach Classic compare-and-contrast question 3 Characteristics of the database approach Often a list-and-explain question 4 Components of a database system Short answer, 5 components 5 People in database systems Roles of DBA, designers, users 6 Three-schema architecture and data independence High-mark, diagram-based question 7 Schemas and instances Short definitions with example 8 Data models Comparison table 9 Database languages: DDL, DML, DCL, TCL Identify the category of a statement 10 DBMS architecture and components Explain components and tiers 11 Advantages and disadvantages of DBMS Discuss / justify questions 12 Database system development life cycle List and explain stages 13 Glossary of key terms Quick definitions 14 Practice questions with answers Test yourself 15 One-page revision summary Last-minute review
How to use this guide
Read sections 1 to 12 once, attempt the practice questions in section 14 without looking at the
answers, then use section 15 the night before the exam.
Where your lecturer uses different terminology or emphasis, add your own notes in the margins.
Exam tip
Do not confuse the three terms. The database is the data, the DBMS is the software that
manages it, and the database system is everything together. Many students lose marks by using
"database" and "DBMS" as if they mean the same thing.
2. File-Based Systems vs the Database Approach
Before DBMSs, organizations stored data in separate files, each used by its own application program.
For example, a college might keep one file for the registry, another for the finance office, and
another for the library. This worked for small tasks but caused serious problems.
2.1 Problems of file-based systems
Problem Explanation Example Data redundancy The same data is stored in many files, wasting space A student's address stored in registry, finance, and library files Data inconsistency Copies of the same data disagree after partial updates Address updated in registry but not in finance Difficulty accessing data Each new query needs a new program to be written List students owing fees AND borrowing books requires new code Data isolation Data is scattered across files in different formats One file is a text file, another is a spreadsheet Integrity problems Rules (constraints) are buried in program code and hard to change Minimum balance rule hard-coded in many programs Atomicity problems A failure in the middle of an operation leaves data half-updated Money debited from one account but not credited to the other Concurrent access anomalies Two users updating the same record can overwrite each other Two clerks updating the same stock count at once Security problems Hard to give different users different access rights All-or-nothing access to a file
2.2 File system vs DBMS: side-by-side
Feature File-based system DBMS Data storage Separate files per application Central, integrated database Redundancy High Controlled and minimized Consistency Hard to maintain Enforced by the DBMS Data independence None; structure is in the program Programs are insulated from storage details Query facility Needs custom programs Query language such as SQL
Feature File-based system DBMS Concurrent access Poorly supported Supported through concurrency control Backup and recovery Manual, limited Built-in recovery mechanisms Security Limited User accounts, privileges, and roles Cost and complexity Cheaper and simpler More expensive and complex
3. Characteristics of the Database Approach
3.1 Self-describing nature
A database contains not only the data but also a complete description of its structure and
constraints. This description is called metadata and is stored in the system catalog (also called the
data dictionary ). The catalog records table names, column names, data types, keys, constraints, and
users. DBMS software uses the catalog to work with any database, whereas a file-based program is
written for one specific file structure.
3.2 Insulation between programs and data (program-data independence)
The structure of data files is stored in the catalog, not in application programs. So you can change
the structure (for example, add a column) without rewriting every program that uses the database.
3.3 Data abstraction
A DBMS gives users a conceptual representation of data and hides storage details such as how files
are organized or which indexes exist. A data model is the tool that provides this abstraction.
3.4 Support for multiple views
Different users need different parts of the data. A view is a subset of the database, or data derived
from it, that is not stored separately. For example, a lecturer sees student marks, while the finance
officer sees student fee balances.
3.5 Sharing of data and multiuser transaction processing
Many users must be able to access the database at the same time. The DBMS includes concurrency
control so that simultaneous updates do not corrupt the data. A transaction is a unit of work, and
the DBMS guarantees properties known as ACID (Atomicity, Consistency, Isolation, Durability), which
are covered in detail in a later guide.
3.6 Other characteristics
- Control of redundancy: the data is stored once, in one place, wherever possible.
- Enforcing integrity constraints: the DBMS checks that data follows the rules (for example, a
unique ID or a valid date).
- Restricting unauthorized access: user accounts and privileges control who can see or change
what.
Type of end user How they use the database Example Sophisticated users Write their own queries to meet complex needs Analysts, engineers, scientists Standalone users Maintain personal databases using ready- made packages Someone keeping a personal finance database
5.4 System analysts and application programmers
System analysts study user requirements and produce specifications for transactions. Application
programmers implement those specifications as programs and test them.
6. Three-Schema Architecture and Data Independence
The three-schema architecture separates the user applications from the physical database. It was
proposed so that the system supports data abstraction, multiple views, and a self-describing catalog.
It has three levels:
Level Schema Describes Who uses it External (view) level External schemas / user views The part of the database a particular user group sees; hides the rest End users, application programs Conceptual (logical) level Conceptual schema The structure of the whole database: entities, attributes, relationships, constraints; hides storage details DBAs, designers Internal (physical) level Internal schema How data is physically stored: file structures, indexes, access paths DBMS, system programmers External view 1 External view 2 External view 3 \ | / +--------- Conceptual schema ---------+ | Internal schema | Stored database (disk)
The DBMS converts requests between levels using mappings : external/conceptual mapping and
conceptual/internal mapping.
6.1 Data independence
Data independence is the ability to change the schema at one level without having to change the
schema at the next higher level.
Type Meaning Example Logical data independence Change the conceptual schema without changing external schemas or application programs Add a new column "Email" to the Student table without breaking existing views and programs
Type Meaning Example Physical data independence Change the internal schema without changing the conceptual schema Move the database to a new disk, or add an index, with no change to the table structure
Exam tip
Physical data independence is easier to achieve than logical data independence, because changes
to the conceptual schema (such as removing an attribute) usually affect the views that depend
on it.
7. Schemas and Instances
The database schema is the description of the database: its structure, data types, and constraints. It
is specified during design and does not change often. The schema is sometimes called the intension.
The database instance (or database state ) is the actual data stored in the database at a particular
moment. It changes every time data is inserted, updated, or deleted. The instance is sometimes
called the extension.
Worked example
Schema: STUDENT(StudentID, Name, Course, Year)
Instance at 9:00 am on Monday:
StudentID Name Course Year S001 Achieng Computer Science 2 S002 Brian Information Technology 1 S003 Chebet Computer Science 3
If a new student is added, the instance changes, but the schema stays the same. Adding a new
column "Email" would change the schema.
8. Data Models
A data model is a collection of concepts used to describe the structure of a database, including data
types, relationships, and constraints. Models can be grouped by how close they are to the user or
the machine:
- Conceptual (high-level) models are close to how users see data. The Entity-Relationship (ER)
model is the best known.
- Representational (implementation) models are understood by users and also close to how
data is stored. The relational model is the most widely used.
- Physical (low-level) models describe how data is stored in files, including record formats and
access paths.
9.3 Data Control Language (DCL)
DCL controls access to the data through privileges.
GRANT SELECT, INSERT ON Student TO clerk; REVOKE INSERT ON Student FROM clerk;
9.4 Transaction Control Language (TCL)
TCL manages transactions.
COMMIT; -- make changes permanent ROLLBACK; -- undo changes since the last commit SAVEPOINT s1; Category Purpose Commands DDL Define structure CREATE, ALTER, DROP, TRUNCATE DML Manipulate data SELECT, INSERT, UPDATE, DELETE DCL Control access GRANT, REVOKE TCL Control transactions COMMIT, ROLLBACK, SAVEPOINT
Exam tip
Some textbooks place SELECT in its own category called DQL (Data Query Language). Check how
your lecturer classifies it, and use the same classification in your answers.
10. DBMS Architecture and Components
10.1 Main components of a DBMS
Component Role DDL compiler Processes schema definitions and stores metadata in the catalog DML compiler / query processor Parses and translates queries into low-level instructions Query optimizer Chooses the most efficient way to execute a query Query evaluation engine Executes the chosen plan Storage manager Interface between stored data and the application; handles files, buffers, and indexes Transaction manager Ensures ACID properties and handles concurrency and recovery Authorization and integrity manager Checks user rights and integrity constraints System catalog (data dictionary) Stores metadata about the database
10.2 Client-server and tier architectures
Architecture Description Example 1 - tier User, application, and database on the same machine A desktop application using SQLite 2 - tier Client application talks directly to the database server A desktop app connecting to a MySQL server 3 - tier Client (presentation) ↔ application server (business logic) ↔ database server A web application: browser → web server → database
3 - tier architecture is common in web applications because it improves security (clients never touch
the database directly), scalability, and maintainability.
11. Advantages and Disadvantages of a DBMS
Advantages
- Controls data redundancy and reduces inconsistency
- Allows data to be shared by many users and applications
- Enforces integrity constraints and standards
- Provides security through authorization
- Provides backup and recovery services
- Provides data independence, reducing application maintenance cost
- Supports ad hoc queries through a query language, giving faster access to information
- Supports concurrent access with consistency
Disadvantages
- High initial cost of software, hardware, and training
- Complexity of the system and need for skilled staff
- Can be slower than a simple file system for very small or specialized tasks
- The database becomes a single point of failure, so backup and recovery are essential
- Higher impact of a failure, because many applications depend on it
When not to use a DBMS
A DBMS may be unnecessary when the data and applications are simple and unchanging, when
there are strict real-time requirements that the DBMS overhead cannot meet, when no multiuser
access is needed, or when the cost cannot be justified.
Term Definition Transaction A logical unit of work made up of one or more database operations View A virtual table defined from one or more tables; the user's window into the data
14. Practice Questions with Answers
Try each question on paper first, then check your answer. Marks are suggestions only.
Question 1. Define the terms "data", "information", and "database". (3 marks)
Answer: Data is raw, unprocessed facts. Information is data that has been processed and given
meaning so it can support decisions. A database is an organized collection of logically related
data that represents some part of the real world and is designed for a specific purpose.
Question 2. Distinguish between a database and a DBMS. (2 marks)
Answer: A database is the collection of stored data. A DBMS is the software used to define,
create, maintain, and control access to that database.
Question 3. State five problems of the file-based approach. (5 marks)
Answer: Any five of: data redundancy; data inconsistency; difficulty in accessing data; data
isolation; integrity problems; atomicity problems; concurrent access anomalies; security
problems. Give a one-line explanation for each.
Question 4. Explain how a DBMS solves the problem of data redundancy and inconsistency. (
marks)
Answer: A DBMS keeps data in a central, integrated database rather than in separate files, so
each fact is stored once or under control. Because there is one copy, updates happen in one
place and cannot disagree. Where controlled redundancy is kept (for performance), the DBMS
can enforce consistency through constraints and triggers.
Question 5. What is metadata and where is it stored? (2 marks)
Answer: Metadata is data about data, such as table names, column names, data types, and
constraints. It is stored in the system catalog (data dictionary).
Question 6. Describe the three levels of the three-schema architecture. (6 marks)
Answer: External level: individual user views showing only relevant data. Conceptual level:
describes the entire database logically (entities, relationships, constraints) without storage
details. Internal level: describes physical storage, including file structures and indexes. The DBMS
maps between levels.
Question 7. Differentiate between logical and physical data independence, giving an example of
each. (4 marks)
Answer: Logical independence: changing the conceptual schema without changing external
schemas or programs, for example adding a column to a table. Physical independence: changing
the internal schema without changing the conceptual schema, for example adding an index or
moving files to another disk.
Question 8. A table STUDENT(ID, Name, Course) currently has 200 rows. Distinguish the schema
from the instance. (2 marks)
Answer: The schema is the structure STUDENT(ID, Name, Course) with its data types and
constraints. The instance is the 200 rows currently stored. Adding a row changes the instance
only; adding a column changes the schema.
15. One-Page Revision Summary Topic Key points to remember Definitions Data = raw facts. Information = processed data. Database = organized, related data. DBMS = software to manage it. Database system = database + DBMS + applications. File system problems Redundancy, inconsistency, hard access, isolation, integrity, atomicity, concurrency anomalies, security. DBMS characteristics Self-describing (catalog), program-data independence, data abstraction, multiple views, sharing and transactions. Components Hardware, software, data, procedures, people. People DBA, designers, end users (casual, naive, sophisticated, standalone), analysts, application programmers. Three-schema architecture External (views), conceptual (whole logical design), internal (physical storage). Mappings between levels. Data independence Logical = change conceptual without changing external. Physical = change internal without changing conceptual. Schema vs instance Schema = structure (changes rarely). Instance = data at a moment (changes constantly). Data models Hierarchical, network, relational, ER, object-oriented, document/NoSQL. Languages DDL (structure), DML (data), DCL (access), TCL (transactions). Architecture 1 - tier, 2-tier, 3-tier. 3-tier common for web applications. Life cycle Requirements, conceptual design, logical design, physical design, implementation, testing, maintenance.
Before the exam
Can you draw the three-schema diagram from memory and explain both types of data
independence?
Can you give one real example for every file-system problem?
Can you classify any SQL statement as DDL, DML, DCL, or TCL?