Unit 1 - Week2-Text Learning
Unit 1 - Week2-Text Learning
Database Systems
Database Systems: SQL: Data definition Commands – Database System Architecture – Overview
of SQL – SQL: Data Manipulation commands – Set Operations.
Week 2
Learning Objectives:
Key Topics
1.1 Data definition Commands
1.1.1 Create
1.1.2 Drop
1.1.3 Alter
1.1.4 Truncate
1.2 DBMS System Architecture
1.2.1 Database users and user interfaces
1.2.2 Database Administrator
1.3 Overview of SQL
1.3.1 Rules
1.3.2 Process of SQL
1.3.3 Characteristics of SQL
1.3.4 Advantages of SQL
1.3.5 Types of SQL
1.4 Data Manipulation commands
1.4.1 Insert
1.4.2 Update
1.4.3 Alter
1.5 Set Operations
1.5.1 Union
1|Page
1.5.2 Union All
1.5.3 Intersect
1.5.4 Minus
1.6 Summary
1.1.1 CREATE
1.1.2 DROP
This command can delete an index, table or view. Basically, any component from a relational
database management system can be removed using the Drop command. Once the object is dropped,
it cannot be reused.
Example:
• DROP TABLE EMPLOYEE;
1.1.3 ALTER
An existing database object can be modified using the alter command. Alter command can do
following changes to any table-
2|Page
Drop integrity constraints.
Syntax
General Syntax of the ALTER command is mentioned below −
Example:
• ALTER TABLE STU_DETAILS ADD(ADDRESS VARCHAR2(20));
• ALTER TABLE STU_DETAILS MODIFY (NAME VARCHAR2(20));
1.1.4 TRUNCATE
It is used to delete all the rows from the table and free the space containing the table.
Syntax:
TRUNCATE TABLE table_name;
Example:
TRUNCATE TABLE EMPLOYEE;
Users of database systems can be divided into four categories based on how they anticipate to
interact with the system.
Naive users :
Users who interact with the system through established user interfaces, such as online
or mobile applications, are known as naive users. A forms interface is a standard user interface for
new users, where the user can fill in suitable fields of the form. Users with no access to the database
can also view read reports generated by the database.
3|Page
• Application programmers:
Users with advanced skills interact with the system without having to write programs. Instead,
they use a database query language or tools like data analysis software to construct their
requests. This category includes analysts who send queries to study data in the database.
Storage Manager
The storage manager is a database system component that serves as an interface between the
database's low-level data and the application programs and queries that are sent to it. The relationship
is the responsibility of the storage manager with the help of the file manager.
The raw data is saved on the hard drive using the operating system's file system. The storage
manager converts DML statements into file-system commands at the lowest level. As a result, the
4|Page
storage manager is in charge of storing, Retrieving and updating information from a database.
File Manager:
The file manager is in charge of allocating disc storage space and the data structures that are used to
represent information saved on disc.
Buffer Manager:
– The buffer manager is in charge of getting data from disc storage into main memory and
determining what data to cache there. The buffer manager is an important component of
the database system because it allows the database to process large amounts of data.
– Sizes that are significantly larger than the main memory size.
Data Files:
The database itself is stored in data files.
Data Dictionary:
Data dictionary, which keeps track of metadata on the database's structure, particularly the
schema.
Indices:
– Indices can be used to enable quick access to data objects. A database index, like the
index in this book, gives links to data items that have a specific value.
– For instance, we could use an index to locate the instructor record for a specific course.
A query can usually be converted into one of several different evaluation strategies, all of which yield
the same result. The DML compiler also does query optimization, which means it chooses the least
expensive evaluation plan from a list of options.
– Query evaluation engine which executes low-level instructions generated by the DML
compiler.
5|Page
1.2.2 Database Administrator
One of the key benefits of adopting DBMSs is that they provide central control over both the data and
the programs that use it. A database administrator is someone who has such centralized authority over
the system (DBA).
The functions of a DBA include:
• Schema definition
By executing a set of data definition statements in the DDL, the DBA generates the original
database schema.
• Storage structure and access-method definition.
The DBA may set some parameters for the data's physical organization and the indices that
will be produced.
• Schema and physical-organization modification.
Changes to the schema and physical organization are made by the DBA to reflect the
organization's evolving needs or to improve performance.
• Granting of authorization for data access
The database administrator can control which parts of the database different users have
access to by providing different forms of authorization. When a user attempts to access data in
the system, the database system examines the authorization information in a particular system
structure.
• Routine maintenance:
1.3Overview of SQL
Structured Query Language (SQL) is an acronym for Structured Query Language.
In a relational database management system, it is used to store and manage data (RDMS).It is
a Relational Database System (RDBMS) standard language.
It allows users to make relational databases and tables, as well as read, update, and remove
them. SQL is the standard database language used by every RDBMS, including MySQL,
Informix, Oracle, MS Access, and SQL Server.
1.3.1 Rules
The structure query language does not care about
capitalization. In general, SQL keywords are
6|Page
expressed in uppercase.
SQL statements are based on text lines.
On a single or several text lines, we can utilize a
single SQL statement.
You can conduct the majority of database tasks
with SQL statements.
Tuple relational calculus and relational algebra
are used in SQL.
1.3.2 Process of SQL
– When a SQL command is run against any RDBMS, the system selects the optimal approach
to execute the request, and the SQL engine decides how to interpret the task.
– Various components are used in the process. Optimization Engine, Query Engine, Query
Dispatcher, Classic, and so on are examples of these components.
7|Page
– SQL is capable of executing database queries.
– For describing the data, SQL is employed.
– SQL is a programming language that is used to define and modify data in databases.
– The database and table are created and deleted with SQL.
– A view, stored procedure, or function in a database are all created using SQL
INSERT INTO TABLE_NAME (col1, col2, col3 ... col N) VALUES (value1, value2, value3
... valueN);
Or
8|Page
INSERT INTO TABLE_NAME VALUES (value1, value2, value3 ... valueN);
For example:
INSERT INTO javatpoint (Author, Subject) VALUES ("Sonoo", "DBMS");
1.4.2 UPDATE
UPDATE: This command is used to update or modify the value of a column in the table.
Syntax:
For example:
UPDATE students
SET User_Name = 'Sonoo'
WHERE Student_Id = '3'
This unit summarizes about the definition of database systems and goal of DBMS. Practical
Applications of DBMS and the drawbacks of File Processing system is given clearly. The
content helps the reader to improve the data abstraction and views of Data.
1.4.3 DELETE
The SQL Union operation joins the results of two or more SQL SELECT queries together.
The number of data types and columns in both tables on which the UNION operation is
performed must be the same in order to perform the union operation.
Duplicate rows are removed from the result set using the union method.
Syntax
SELECT column_name FROM table1
9|Page
UNION
SELECT column_name FROM table2;
ID NAME
1 Jack
2 Harley
3 Joseph
• Example: The First Table
ID NAME
3 Joseph
4 Steve
5 Daniel
• The Second Table:
10 | P a g e
• Union SQL query will be:
SELECT * FROM First
UNION
ID NAME
1 Jack
2 Harley
3 Joseph
4 Steve
5 Daniel
• The resultset table will look like:
1.5.2 UNIONALL
Union All operations are equivalent to those of the Union. It returns the set without sorting or
deleting duplicates.
Syntax:
SELECT column_name FROM table1
UNION ALL
SELECT column_name FROM table2;
Example: Using the above first and Second table.
Union All query will be like:
SELECT * FROM First
UNION ALL
SELECT * FROM Second;
ID NAME
11 | P a g e
1 Jack
2 Harley
3 Joseph
3 Joseph
4 Steve
5 Daniel
• The resultset table will look like:
1.5.3 INTERSECT
It's used to join two SELECT statements together.
The common rows from both SELECT statements are returned by the Intersect procedure.
The number of data types and columns in the Intersect operation must be the same.
There are no duplicates, and the data is arranged in ascending order by default.
Syntax
SELECT column_name FROM table1
INTERSECT
SELECT column_name FROM table2;
Example:
Using the above first and Second table.
Intersect query will be:
SELECT * FROM First
INTERSECT
The
ID NAME
3 Joseph
resultset table will look like:
1.5.4 MINUS
12 | P a g e
It combines the results of two SELECT statements into a single statement.
The minus operator is used to show rows that are present in the first query but not in the
second.
There are no duplicates, and the data is sorted ascending by default.
Syntax:
SELECT column_name FROM table1
MINUS
SELECT column_name FROM table2;
Minus query will be:
SELECT * FROM First
MINUS
SELECT * FROM Second;
The resultset table will look like:
ID NAME
1 Jack
2 Harley
1.6 SUMMARY
This unit summarizes about the Overview of SQL and the commands of Data definition and
data manipulation. Detailed explanation of Database system Architecture is given. The content
helps the reader to improve the Set Operations.
References
[1] Abraham Silberschatz, Henry F. Korth, S. Sudharshan, (2011),“Database System Concepts”,
13 | P a g e
Sixth Edition, Tata McGraw Hill
[2] https://www.javatpoint.com/dbms-sql-command
14 | P a g e