CHAPTER 2
• Database system concepts & Architecture
Fundamentals of Database
Database system concepts & Architecture
Database Schema
Database Instances
Schema Diagram
Database System Architecture
Level of Abstraction
Data Independence and Classification of DBMS
Database Languages
Database Interfaces
Fundamentals of Database
Database schema
• A schema is the blueprint or structure of a database that defines how data is
organized, stored, and accessed.
• The actual implementation of the data model in a specific database, defining
tables, columns, data types, and constraints.
• It does not contain actual data but defines the rules and structure for storing data.
• It is often represented using a Data Definition Language (DDL) in SQL. (E.g.,
CREATE TABLE, ALTER TABLE).
Student Course
StudentID, (int, not CourseCode, (int, not null, pk)
null, pk) CourseName,(string)
Name,(string) CreditHr(string)
Email(string)
Examples of Database Schema
CREATE TABLE Students (
Student_id Int Primary Key Auto_Increment,
First_name Varchar(50) not null,
last_name Varchar(50), not null,
Email Varchar(100) unique not null,
Date_of_birth DATE,
Created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
Con’t………………..
CREATE TABLE Courses (
Course_id Int Primary Key Auto_Increment,
Course_name Varchar(100) not null,
Course_code Varchar(20) unique, not null,
Credits INT CHECK (credits > 0),
Instructor varchar(100),
Created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
Con’t………………..
CREATE TABLE Enrollments (
enrollement_id Int Primary Key Auto_Increment,
Student_id INT,
Course_id INT,
Enrollement_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
Grade char(2),
FOREIGN KEY (student_id) REFERENCES Students(student_id) ON DELETE
CASCADE,
FOREIGN KEY (course_id) REFERENCES Courses(course_id) ON DELETE
CASCADE,
UNIQUE(student_id, course_id)
);
Database Instance
• A database instance is the actual data stored in the database at a particular
moment.
• The instance changes frequently as new data is added, modified, or deleted.
• It is a snapshot of the database at a specific time.
CourseID CourseName CreditHr.
101 C++ Programing 3
102 Fundamental of Database System 3
103 Advanced of Database System 3
Schema Diagram
• A schema diagram is a visual representation of a database schema, showing
the structure of tables, their attributes, and relationships between them.
Student enrollment
StudentID(PRIMARY KEY), Enrollment_id(PRIMARY KEY)
FirstName, Student_id (Foreign key students(student_id))
LastName, Course_id int (Foreign key courses (course_id))
DateOfBirth, Enrollment_date TIMESTAMP DEFAULT
Email CURRENT_TIMESTAMP
Grade char(2)
Course
Course_id: (PRIMARY KEY),
Course_name,
Course_code,
Credits,
Instructor,
Created_at:
Three-Schema Architecture
• Known as the ANSI-SPARC architecture.
• the Three-Schema Architecture is a framework used to organize the
components of a Database into three distinct layers.
• This separation ensures that changes in one layer do not affect the others
directly, making the system more flexible and easier to manage.
• The three levels are:
External Schema(View Level):
Conceptual Schema (Logical Level):
Internal Schema (Physical Level):
The Three level of abstraction (The three-schema architecture)
A. Internal Schema (Physical Level):
o also called the storage level and the bottom-most layer of the architecture.
o It represents the how the data are actually stored in physical storage and organization of
data within the database system, including data structures, access methods, and storage
allocation mechanisms.
o Example: consider a university database:
o Data Stored:-
o [Link], [Link], and [Link].
o The Students table stored in a file system using B+ tree indexing on the student_id for fast
lookups.
o The Enrollments table is partitioned by year to improve query performance.
B. Conceptual Schema (Logical Level):
• Known as the intermediate layer of the architecture.
• Specifies what data are stored and what relationships exist?
• This is the complete, logical structure of the database, defining all tables, columns,
datatypes, relationships, and constraints etc.
• Only one conceptual schema exists per database.
• Example: consider a university database:
• Tables: Students, Courses, Enrollments.
• Relationships:
• StudentID in Enrollments references [Link].
• CourseID in Enrollments references [Link].
• Constraints: StudentID and CourseID in Enrollments cannot be null.
• Grade must be one of: A, A-, B+, B, ETC. (via a CHECK constraint).
C. External Schema (View Level):
• known as user interface level, is the topmost layer of the architecture.
• This level represents how different users or applications interact with the database and hides the rest of
the database from the user.
• Each user group sees only the data relevant to them.
• Example: consider a university database:
• A student view: logs into the university portal and sees:
• Their student ID, NAME, list of courses they enrolled in, including course names and instructor names, their
grades for completed courses.
• Teacher view: logs into the university portal and sees:-
• A list of courses they are teaching, a roster of students ned in each course, including student IDs, and names.
Why Three-Schema Architecture
oData Independence: All three levels are separate from one
another. As a result, we can update one layer without affecting the
others.
If the university decides to change the physical storage of the student data
(internal schema), the student’s view (external schema) remains
unchanged.
If a new attribute is added to the Students table (conceptual schema), it
doesn’t necessarily affect the instructor’s view.
oEnsures security and restricted access : Users only see
what they are allowed to via the external schema.
oAbstraction: Hides complexity from end users.
Data Independence
• The capacity to change the schema at one level of a database system
without changing the schema at the next higher level.
• Two types of data independence:-
1. Logical data independence
2. Physical data independence
1. Logical Data Independence: The ability to change the conceptual schema
without affecting the external schema(user views).
Examples:
Adding a new table, column, or relationship in the database does not require
changes to the existing user views or application programs.
Changing relationships between tables.
Modifying constraints.
Consider a University database with a Students table:
Student View
STUDENT_ID NAME AGE DEP’T STUDENT_ID DEP’T
101 Abdi 22 CS 101 CS
102 Bonsa 24 IT 102 IT
If we add a new attribute ‘EMAIL’ to Student table:
STUDENT_ID NAME AGE DEP’T EMAIL
101 Abdi 22 CS abdi@[Link]
102 Bonsa 24 IT bonsa@[Link]
This modification does not affect the views or applications that only retrieve
Student_id and department, ensuring logical data independence.
Physical Data Independence
• Physical data independence: The ability to change the internal
schema (physical storage) without affecting the conceptual schema
or external schemas.
Examples: Suppose you have a university database where the student
table is stored on a hard disk with a B-tree indexing strategy.
o Moving from HDD to SSD Storage for better performance.
o Changing the indexing technique from B-tree to Hash indexing.
DBMS Languages
Database languages are used for read, update and store in a
database.
• The different types of DBMS languages are as follows:-
1. Data Definition Language(DDL)
2. Data Manipulation Language(DML)
3. Data Control Language(DCL)
4. Transaction Control Language(TCL)
DBMS Languages……..Con’t...
Data Definition Language(DDL): used to create and modify the structure of database objects
in a database.
• Here are some commands under DDL:
Create: It is used to create objects in the database. (database, table).
Alter: It is used to alter the structure of the database.
• (add new column to existing table, change data type and size of column, delete existing
column).
Drop: It is used to delete objects from the database. (database, table).
Rename: It is used to rename an object.
• Change database name, table name and column name.
DBMS Languages……..Con’t...
Data Manipulation Language(DML):
• It is a language that provides a set of operations to support the basic data
manipulation operation on data held in the database.
The following operations on database comes under DML:
Select: It is used to retrieve data from a database.
Insert: It is used to insert data into a table.
Update: It is used to update existing data within a table.
Delete: It is used to delete all records from a table.
DBMS Languages……..Con’t...
Data Control Language (DCL):
• DCL is used for granting and revoking user access on a database.
To grant access to user – GRANT
To revoke access from user -- REVOKE
Transaction Control Language(TCL):
• A language which manages the transactions within the database
• A transaction is an action or series of actions.
• TCL is used to run the changes made by DML statement.
To persist the changes made by DML commands in database --- COMMIT.
To rollback the changes made to the database --- ROLLBACK
DBMS Interface
• A DBMS interface is the mechanism that allows users (humans or applications)
to interact with the database.
Types of Database Interfaces:
• Menu based Interfaces (for the web clients or browsing)
• Forms-Based Interfaces
• Graphical User Interfaces(GUI)
• Natural Language Interfaces
• Speech Input and Output
• Interface for the DBA
Menu based Interfaces
• These interfaces present users with a series of menus from which they can select options to
perform database operations.
• They are usually simple to navigate and don’t require knowledge of SQL or programming.
Examples:
• phpMyAdmin: A web-based interface for managing MySQL databases that offers a
menu-driven approach to perform tasks like creating databases, tables, and running
queries.
• Oracle SQL Developer: Provides a menu interface to interact with Oracle databases,
allowing users to execute SQL commands and manage database objects without writing
SQL.
Forms-Based Interfaces
• Forms-based interfaces allow users to input data into structured forms, often used
for data entry and modification.
• These interfaces validate input and ensure data integrity.
Examples:
• Microsoft Access: Users can create forms to enter data into tables, making it
easier to collect and manipulate data without direct SQL interaction.
• Web Forms: Custom web applications often use forms for user input, such as
registration or survey forms that interact with a database backend.
Graphical User Interfaces (GUI)
• GUIs provide a visual representation of the database, allowing users to interact
with it through graphical elements like buttons, icons, and visual layouts.
Examples:
• MySQL Workbench: Offers a GUI for designing databases, running queries, and
managing database objects visually.
• Microsoft SQL Server Management Studio (SSMS): A comprehensive GUI
tool that allows database administrators to manage SQL Server databases visually
through a user-friendly interface.
Natural Language Interfaces
• These interfaces allow users to interact with the database using natural language queries, making it
easier for non-technical users to retrieve information.
Examples:
• IBM Watson Discovery: Uses natural language understanding to allow users to ask questions and
retrieve relevant data from databases.
• Google BigQuery: Users can query data using plain English phrases, which are then translated into SQL
queries by the system.
E.g., User: “ Show me all students enrolled in Database Systems.”
System: SELECT * FROM Students WHERE Course = ‘Database System’;
User: “Show me all employees.”
System: SELECT * FROM employees;
Speech Input and Output
• Speech interfaces enable users to interact with databases using voice commands, making it more
accessible, especially for hands-free environments.
Examples:
• Amazon Alexa and Google Assistant: These voice assistants can be integrated with database
applications to retrieve information based on voice commands (e.g., “Show me today’s sales figures”).
• Voice-Activated Database Systems: Custom applications that allow users to perform database queries
through voice input, receiving spoken responses.
User: “Add a new student named ABDI.”
System: Insert into students (Name) VALUES (“ABDI”);
Interface for the Database Administrator (DBA)
• These interfaces are tailored for database administrators, providing tools for
performance monitoring, backup, recovery, and overall database management.
Examples:
• Oracle Enterprise Manager: A comprehensive monitoring and management tool for
Oracle databases, offering features for tuning, backup, and recovery.
• pgAdmin: A management tool for PostgreSQL databases that provides a variety of
administrative features, including monitoring database performance and managing user
access.
TH
E
EN
D!