Database Management Systems Lecture Notes
Database Management Systems Lecture Notes
Sub-topics
A Database Management System (DBMS) is application software that allows creation, definition
and manipulation of database contents, allowing users to store, process and analyze data easily.
DBMS provides us with an interface or a tool, to perform various operations like creating
database, storing data in it, updating data, creating tables in the database etc.
A DBMS has several components, each performing very significant tasks in the database system
environment. Below is a list of components of a DBMS:-
Note: Data type in programming languages refer to the format of data supported by a specific
language
1. The CREATE DDL command: This command is used to create objects such as Tables,
Views and databases.
Practice Exercises:
Command syntax: CREATE table tableName (attribute names and data types);
Answer:
Command syntax: CREATE table tableName (attribute names and data types);
CREATE table students (studentIDNumber integer, Firstname text, Surname text, emailaddress
varchar(17), Feebalance integer, primary key(studentIDNumber));
In SQL, a view is a virtual table based on the result set of an SQL statement. A view
contains rows and columns just like a real table. The fields in a view are fields from a real
table in the database.
In SQL views are created using the command syntax shown below:
Exercise 1:
Using the course relation, create a view named DITCourses to extract CourseCode ,
CourseName andCourseDepartment for all courses offered by IT department
Exercise 2:
1. INSERT Command
2. SELECT Command
3. UPDATE Command
4. DELETE Command
1) INSERT: This command adds one or more records to a database table. The insert
command syntax is
Exercise:
2) SELECT: used to retrieve data inform of records (rows) from a database table.
The select command syntax is: SELECT [column name(s)] from [table name] where
[conditions]; Select is the most widely used DML command in SQL.
Exercise: - Write SQL command to extract all the student records from the student
relation
3) UPDATE: used to modify data of one or more records. The update command syntax is:
UPDATE table_name SET column_name = new value where [condition];
Exercise: using the student relation, update the first record surname from kamau to
Otieno
4) DELETE: This command removes one or more records from a table according to
specified conditions.
Delete command syntax is: DELETE FROM table name where [condition];
3) Application Generation Subsystem: - the part of the system that contains all the
facilities that could be used to help the user develop transaction intensive applications.
This procedure will usually require the user to perform complex and detailed tasks to
complete the transaction. This is where the Application Generation Subsystem comes in
useful as it provides easy to use screens where you enter the data, programming
languages and interfaces.
4) DBMS engine:-A DBMS engine is the part of the system that accepts and deals with
logical requests that are received from a variety of other DBMS subsystems. It then
works to convert them into physical equivalents and will then gain access to the database
along with its data dictionary as they are on a storage device.
5) Data administration subsystem: - helps users with managing the overall database
environment. It does this by providing facilities that give the user options for backup and
recovery of lost data, managing the system's security, query optimization, concurrency
control and change management.
6) Data Dictionary/ System Catalog Management/ Metadata repository: a data
dictionary is a collection of descriptions of the data objects or items in a database (data
about data). The DBMS provides a data dictionary function in which descriptions of data
items are stored and which is accessible to users.
1. Data is stored in form of Tables/ Relations/ files: Data is never directly stored into the
database i.e. Data is stored into tables, created inside the database. DBMS also allows
having relationships between tables which makes the data more meaningful and
connected. You can easily understand what type of data is stored by looking at all the
tables created in a database.
2. Reduced Redundancy: DBMS follows Normalization which divides the data in such a
way that repetition is minimized.
3. Data Consistency: On Live data, i.e. data that is being continuously updated and added,
maintaining the consistency of data can become a challenge. But DBMS handles it all by
itself.
4. Support multiple user and Concurrent Access: DBMS allows multiple users to work
on the database data by updating, inserting or deleting data at the same time and still
manages to maintain the data consistency.
5. Query Language: DBMS provides users with a simple Query language which supports
query statements which can allow the database user to easily fetch data, insert, delete and
updated in the database contents.
6. Data Integrity: - The DBMS can ensure that no more than one user can update the same
record at the same time. It can keep duplicate records out of the database; for example, no
two customers with the same customer number can be entered.
7. Security: The DBMS also takes care of the security of data, protecting the data from un-
authorized access. A DBMS can be used to create user accounts with different access
permissions that can be used to restrict non-authorized user from accessing the database.
8. Data Independence:-When a DBMS is used, the details of the data structure are not
stated in each application program. The program asks the DBMS for data by field name;
for example, a coded equivalent of "give me customer name and balance due" would be
sent to the DBMS. Without a DBMS, the programmer must reserve space for the full
structure of the record in the program. Any change in data structure requires changing all
application programs.
9. DBMS supports transactions, which allows us to better handle and manage data
integrity which is a core requirement of a database system.
database. DBMSs ensure that the database is kept in consistent state and that integrity of
the data is preserved.
9) Transaction Management: A transaction is a set of database operations, carried out by a
single user or application program, which accesses or changes the contents of the
database. Therefore, a DBMS must provide a mechanism to ensure either that all the
updates corresponding to a given transaction is made or that none of them is made.
10) Database Access and Application Programming Interfaces: All DBMS provide
interface to enable applications to use DBMS services. They provide data access via
Structured Query Language (SQL). The DBMS query language contains two
components: (a) a Data Definition Language (DDL) and (b) a Data Manipulation
Language (DML).