0% found this document useful (0 votes)
18 views24 pages

5.unit 5

The document provides comprehensive lecture notes on Database Management Systems (DBMS), focusing on SQL query construction, data types, and various SQL commands including DDL, DML, DCL, and TCL. It covers basic SQL queries, comparison and logical operators, as well as advanced topics like data warehousing and NoSQL databases. The course aims to equip students with the ability to design entity-relationship models and formulate SQL queries effectively.

Uploaded by

Sami Ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views24 pages

5.unit 5

The document provides comprehensive lecture notes on Database Management Systems (DBMS), focusing on SQL query construction, data types, and various SQL commands including DDL, DML, DCL, and TCL. It covers basic SQL queries, comparison and logical operators, as well as advanced topics like data warehousing and NoSQL databases. The course aims to equip students with the ability to design entity-relationship models and formulate SQL queries effectively.

Uploaded by

Sami Ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

Lecture Notes for DBMS

UNIT – V
Form of Basic SQL Query, Examples of Basic SQL Queries, Introduction to Nested Queries, Correlated
Nested Queries Set, Comparison Operators, Aggregative Operators, NULL values,
Comparison using Null values, Logical connectivity‘s – AND, OR and NOT, Impact on SQL Constructs,
Outer Joins, Disallowing NULL values, Complex Integrity Constraints in SQL Triggers and Active Data
bases.
Advanced Topics: Overview: Parallel Database, Multimedia Database, Mobile Database, Web
Database, Multi dimensional Database. Data Warehouse, OLTP Vs OLAP, NoSQL Database.

COURSE OBJECTIVES:
To master the basics of SQL and construct queries using SQL
COURSE OUTCOMES:
✓ Ability to design entity relationship model and convert entity relationship diagrams into RDBMS
and formulate SQL queries on the data

SQL (STRUCTURED QUERY LANGUAGE)


SQL is a database computer language designed for managing data in relational database management
systems (RDBMS), and originally based upon Relational Algebra. Its scope includes data query and
update, schema creation and modification, and data access control. SQL was one of the first languages
for Edgar F. Codd's relational model in his influential 1970 paper, "A Relational Model of Data for
Large Shared Data Banks" and became the most widely used language for relational databases.
• IBM developed SQL in mid of 1970’s. Oracle incorporated in the year 1979.
• SQL used by IBM/DB2 and DS Database Systems.
• SQL adopted as standard language for RDBS by ASNI in 1989.

Form of Basic SQL Query:


SELECT Attributes List
FROM Relation/Table Name
[WHERE Condition];
• SELECT is one of the fundamental query command of SQL. It is similar to the projection
operation of relational algebra. It selects the attributes based on the condition in WHERE clause.
• FROM clause takes a relation/table name as an argument from which attributes are to be selected
/ projected.
• WHERE clause defines predicate or condition, which must match in order to qualify the
attributes to be projected.
1
Lecture Notes for DBMS

COMPARISON OPERATORS:

Assume 'variable a' holds 10 and 'variable b' holds 20, then

Operator Description Example


Checks if the values of two operands are equal or not, if yes
= (a = b) is not true.
then condition becomes true.
!= (or) <> Checks if the values of two operands are equal or not, if values
(a <> b) is true.
are not equal then condition becomes true.
Checks if the value of left operand is greater than the value of
> (a > b) is not true.
right operand, if yes then condition becomes true.
Checks if the value of left operand is less than the value of right
< (a < b) is true.
operand, if yes then condition becomes true.
Checks if the value of left operand is greater than or equal to
>= (a >= b) is not true.
the value of right operand, if yes then condition becomes true.
Checks if the value of left operand is less than or equal to the
<= (a <= b) is true.
value of right operand, if yes then condition becomes true.

Logical connectivity‘s:
• AND: The AND operator allows the existence of multiple conditions in an SQL statement's
WHERE clause.
• OR: The OR operator is used to combine multiple conditions in an SQL statement's WHERE
clause
• NOT: The NOT operator reverses the meaning of the logical operator with which it is used.
Eg: NOT EXISTS, NOT BETWEEN, NOT IN, etc. This is a negate operator.

DATA TYPES

1. CHAR (Size): It is used to store character strings values of fixed length. Size in brackets determines
number of characters cell can hold. CHAR data type can hold a maximum of 255 characters.
2. VARCHAR (Size) / VERCHAR2 (Size): This data type is used to store variable length alphanumeric
data. The maximum character can hold is 2000 character.
3. NUMBER (P, S): The NUMBER data type is used to store number (fixed or floating point). Number
of virtually any magnitude may be stored up to 38 digits of precision. Number as large as 9.99 *

2
Lecture Notes for DBMS

10124. The precision (p) determines the number of places to the right of the decimal. If scale is
omitted then the default is zero. If precision is omitted, values are stored with their original precision
up to the maximum of 38 digits.
4. DATE: This data type is used to represent date and time. The standard format is DD-MM-YY as in
24-MAR-2022. To enter dates other than the standard format, use the appropriate functions. Date time
stores date in the 24-Hours format. By default the time in a date field is 12:00:00 am, if no time
portion is specified. The default date for a date field is the first day the current month.
5. LONG: This data type is used to store variable length character strings containing up to 2GB. Long
data can be used to store arrays of binary data in ASCII format. LONG values cannot be indexed, and
the normal character functions such as SUBSTR cannot be applied.
6. RAW: The RAW data type is used to store binary data, such as digitized picture or image. Data
loaded into columns of these data types are stored without any further conversion. RAW data type
can have a maximum length of 255 bytes. LONG RAW data type can contain up to 2GB.

SQL language is sub-divided into several language elements, including:


▪ Clauses, which are in some cases optional, constituent components of statements and queries.
▪ Expressions, which can produce either scalar values or tables consisting of columns and rows of
data.
▪ Predicates which specify conditions that can be evaluated to SQL three-valued logic (3VL)
Boolean truth values and which are used to limit effects of statements, queries, or to change
program flow.
▪ Queries which retrieve databases on specific criteria.
▪ Statements which may have a persistent effect on schemas and data, or which may control
transactions, program flow, connections, sessions, or diagnostics.
▪ SQL statements also include the semicolon (";") statement terminator. Though not required on
every platform, it is defined as a standard part of the SQL grammar.
▪ Insignificant white space is generally ignored in SQL statements and queries, making it easier to
format SQL code for readability.

EXAMPLES OF BASIC SQL QUERIES

DATA DEFINITION LANGUAGE (DDL): The Data Definition Language (DDL) is used to
create and destroy databases and database objects. These commands will primarily be used by database
administrators during the setup and removal phases of a database project. Let's take a look at the structure
and usage of four basic DDL commands:

3
Lecture Notes for DBMS

1. CREATE 2. ALTER 3. DROP 4. RENAME

1. CREATE:

CREATE TABLE: This is used to create a new relation and the corresponding
Syntax: SQL > CREATE TABLE tablename (field_1 data_type (Size), field_2 data_type (Size), .. . );
Example: SQL > CREATE TABLE Student (sno NUMBER (3), sname VARCHAR (30), class
VARCHAR (15));

2. ALTER:
(a) ALTER TABLE ...ADD: This is used to add some extra fields into existing relation.
Syntax: SQL > ALTER TABLE relation_name ADD (new field_1 data_type(size), new field_2
data_type(size),..);
Example: SQL > ALTER TABLE std ADD (Address CHAR (10));

(b) ALTER TABLE...MODIFY: This is used to change the width as well as data type of fields of
existing relations.
Syntax: SQL > ALTER TABLE relation_name MODIFY (field_1 new data_type (Size), field_2 new
data_type (Size),….field_n new data_type (Size));
Example: SQL>ALTER TABLE student MODIFY (sname VARCHAR (10), class VARCHAR (5));

3. DROP: This is used to delete the structure of a relation. It permanently deletes the records in the
table.
Syntax: SQL > DROP TABLE table_name;
Example: SQL > DROP TABLE student;

4. RENAME: It is used to modify the name of the existing database object.


Syntax: SQL> RENAME TABLE old_relation_name TO new_relation_name;
Example: SQL>RENAME TABLE std TO std1;

4
Lecture Notes for DBMS

5. TRUNCATE: This command will remove the data permanently. But structure will not be removed.
Syntax: SQL> TRUNCATE TABLE <Table name>
Example: SQL> TRUNCATE TABLE student;

Difference between Truncate & Delete:-


✓ By using truncate command data will be removed permanently & will not get back where as by
using delete command data will be removed temporally & get back by using roll back command.
✓ By using delete command data will be removed based on the condition where as by using
truncate command there is no condition.
✓ Truncate is a DDL command & delete is a DML command.

DATA MANIPULATION LANGUAGE (DML): The Data Manipulation Language (DML)


is used to retrieve, insert and modify database information. These commands will be used by all database
users during the routine operation of the database. Let's take a brief look at the basic DML commands:
1. INSERT 2. UPDATE 3. DELETE 4. SELECT
1) INSERT: This is used to add records into a relation. There are three type of INSERT commands
which are as:

a) Inserting a single record:


Syntax: SQL> INSERT INTO table_name (field_1,field_2,.field_n) VALUES (data_1,data_2,.
data_n);

Example: SQL > INSERT INTO student (sno, sname, class, address) VALUES
(1,’Ravi’,’B.E’,’Hyderabad’);

b) Inserting multiple records:


Syntax: SQL > INSERT INTO table_name (field_1, field_2, . . . ., field_n) VALUES (&data_1,
&data_2, ..., &data_n);

Example: SQL > INSERT INTO student (sno, sname, class, address) VALUES (&sno, ’&sname’,
’&class’, ’&address’);
Enter value for sno: 101
Enter value for name: Ravi

5
Lecture Notes for DBMS

Enter value for class: B.E


Enter value for name: Hyderabad

2) UPDATE: This is used to update the data of a record in a relation/table.

Syntax: SQL > UPDATE table_name SET field_name1=data, field_name2=data,……


WHERE field_name=data;
Example: SQL > UPDATE student SET sname = ‘kumar’ WHERE sno=1;

3) DELETE: This is used to delete all the records of a relation but it will retain the structure of that
relation.
a) DELETE-FROM: This is used to delete all the records of relation. Syntax:
SQL>DELETE FROM relation_name;

Example: SQL>DELETE FROM std;

b) DELETE-FROM-WHERE: This is used to delete a selected record from a relation.


Syntax: SQL>DELETE FROM relation_name WHERE condition;
Example: SQL>DELETE FROM student WHERE sno = 2;

4) SELECT: Retrieves data from one or more tables.

1. SELECT * FROM: To display all fields for all records.


Syntax: SQL> SELECT * FROM relation_name; Example:
SQL> SELECT * FROM dept;
DEPTNO DNAME LOC
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON

2. SELECT FROM: To display a set of fields for all records of relation.


Syntax: SQL > SELECT a set of fields FROM relation_name;
Example: SQL> select deptno, dname from dept;
6
Lecture Notes for DBMS

DEPTNO DNAME
10 ACCOUNTING
20 RESEARCH
30 SALES

3. SELECT - FROM - WHERE: This query is used to display a selected set of fields for a selected set
of records of a relation.
Syntax: SQL> SELECT a set of fields FROM relation_name WHERE condition; Example:
SQL> select * FROM dept WHERE deptno<=20;
DEPTNO DNAME LOC
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS

4. SELECT - FROM - ORDER BY: This query is used to display a selected set of fields from a relation
in an ordered manner base on some field.
Syntax: SQL> SELECT a set of fields FROM relation_name ORDER BY field_name;
Example: SQL> SELECT empno,ename,job FROM emp ORDER BY job;
EMPNO ENAME JOB
3 RAVI MANAGER
2 ARAVIND MANAGER
1 SAGAR CLERK

5. SELECT - FROM - GROUP BY: This query is used to group to all the records in a relation together
for each and every value of a specific key(s) and then display them for a selected set of fields the
relation.
Syntax: SQL> SELECT a set of fields FROM relation_name GROUP BY field_name;
Example: SQL> SELECT EMPNO, SUM (SALARY) FROM EMP GROUP BY EMPNO;
EMPNO SUM (SALARY)
1 3000
2 4000
3 5000

7
Lecture Notes for DBMS

DATA CONTROL LANGUAGE (DCL): DCL provides users with privilege commands. The
owner of database objects (tables) has the soul authority on them. The owner (database administrators)
can allow other database users to access the objects as per their requirement.

1. GRANT: The GRANT command allows granting various privileges to other users and allowing
them to perform operations within their privileges.
For Example, if user is granted ‘SELECT’ privilege then user can only view data but cannot perform
any other DML operation on database object. Granted privileges can also be withdrawn by DBA at any
time.
Syntax: SQL > GRANT PRIVILEGES on object_name To user_name;

Example: SQL > GRANT SELECT, UPDATE on emp To hemanth;

2. REVOKE: To withdraw the privileges that has been granted to a user, we use the REVOKE
command
Syntax: SQL > REVOKE PRIVILEGES ON object-name FROM user_name;

Example: SQL > REVOKE SELECT, UPDATE ON emp FROM ravi;

TRANSACTIONAL CONTROL LANGUAGE (TCL): A transaction is a logical unit of


work. All changes made to the database can be referred to as a transaction. Transaction changes can be
made permanent to the database only if they are committed a transaction begins with an executable SQL
statement & ends explicitly with either rollback or commit statement.

1. COMMIT: This command is used to end a transaction only with the help of the commit
command transaction changes can be made permanent to the database. Syntax: SQL > COMMIT;

Example: SQL > COMMIT;

2. SAVEPOINT: SAVEPOINTs are like marks to divide a very lengthy transaction to smaller
once. They are used to identify a point in a transaction to which we can latter rollback. Thus,
SAVEPOINT is used in conjunction with rollback.
Syntax: SQL > SAVEPOINT ID;

Example: SQL > SAVEPOINT xyz;

8
Lecture Notes for DBMS

3. ROLLBACK: A rollback command is used to undo the current transactions. We can rollback
the entire transaction so that all changes made by SQL statements are undo (or) rollback a transaction
to a SAVEPOINT so that the SQL statements after the SAVEPOINT are rollback.
Syntax: SQL > ROLLBACK; (current transaction can be rollback)
(Or)
SQL > ROLLBACK to SAVEPOINT ID;

Example: SQL > ROLLBACK to SAVEPOINT xyz;

Aggregative Functions/Operators: Aggregate functions in DBMS take multiple rows from the
table and return a value according to the query. All the aggregate functions are used in Select statement.
Generally used Aggregate functions in SQL are:
1. Max (): Max () is used to find maximum value in the column. It can be used on any type of data.
Ex: Select Max (salary) from Employee;

2. Min (): Min () is used to find maximum value in the column. It can be used on any type of data.
Ex: Select Min (salary) from Employee;

3. Sum (): Sum () function sums up the values in the column supplied as a parameter. Ex: Select Sum
(salary) from Employee;

4. Count (): Count () returns the number of rows in the result. It does not count the null values. Ex:
Select COUNT(*) from Employee where Salary > 20000;
Types:
• COUNT(*): Counts all the number of rows of the table including null.
• COUNT( COLUMN_NAME): count number of non-null values in column.
• COUNT( DISTINCT COLUMN_NAME): count number of distinct values in a column.

5. Avg (): Avg () returns the average value of the numeric column that is supplied as a parameter.
Ex: Select Avg (salary) from Employee
INTRODUCTION TO NESTED QUERIES

A Nested Query is a query within another SQL query and embedded within the WHERE clause. It is
also known as Subquery or Complex query.

Rules to construct Nested Queries:


9
Lecture Notes for DBMS

o A subquery is a query within another query. The outer query is known as the main query, and
the inner query is known as a subquery.
o A subquery is enclosed in parentheses. o A subquery can be placed in a number of SQL
clauses like WHERE clause, FROM clause.
o You can use Subquery with SELECT, UPDATE, INSERT, DELETE statements along with the
operators like =, <, >, >=, <=, IN, BETWEEN, etc.
o In the Subquery, ORDER BY command cannot be used.

Syntax:
SELECT column_name
FROM table_name
WHERE column_name expression operator
(SELECT column_name from table_name WHERE ... );

Ex: Select EName, Sal From Employee Where sal = (SELECT Max (Sal) From Employee);

In Nested Query, Inner query executes first, and only once. Outer query is executed with result from
Inner query. Hence, Inner query is used in execution of Outer query.

Correlated Nested Queries Set: In Correlated Query, Outer query executes first and for every
Outer query row Inner query is executed. Hence, Inner query uses values from Outer query.
Ex: Orders (OrderID, CustomerID, OrderDate);
Customers (CustomerID, CustomerName, ContactName, Country);

Find details of customers who have ordered.


Select * From Customers where EXISTS (Select CustomerID From Orders Where
Orders.CustomerID=Customers.CustomerID);

NULL values: The SQL NULL is the term used to represent a missing value. A NULL value in a
table is a value in a field that appears to be blank.
A field with a NULL value is a field with no value. It is very important to understand that a NULL value
is different than a zero value or a field that contains spaces.
Comparison using Null values: It is not possible to test for NULL values with comparison operators,
such as =, <, or <>. We will have to use the IS NULL and IS NOT NULL operators instead.

10
Lecture Notes for DBMS

IS NULL Syntax:
SELECT column_names
FROM table_name
WHERE column_name IS NULL;

IS NOT NULL Syntax:


SELECT column_names
FROM table_name
WHERE column_name IS NOT NULL;

Disallowing NULL values: The integrity constraint NOT NULL while creating the table signifies that
column should always accept an explicit value of the given data type. It does not allow NULL values
into that certain column.

Ex: SQL> CREATE TABLE CUSTOMERS ( ID Number(6) NOT NULL, Name Varchar (20) NOT
NULL, Age Number(2) NOT NULL, Address Varchar (25) , PRIMARY KEY (ID));

Impact on SQL Constructs: The NULL value can cause problems when selecting data. However,
because when comparing an unknown value to any other value, the result is always unknown and not
included in the results.

Outer Joins: In the SQL outer JOIN is used when both tables are integrated together either they are
matched or not. Types of Outer join are:

1. Left Outer Join: This join returns all the rows from left table combine with the matching rows
of the right table. If you get no matching in the right table it returns NULL values. It is also known as
left join Syntax:
SELECT table1.column1, table2.column2....
FROM table1
LEFT JOIN table2
ON table1.column_field = table2.column_field; Ex:
SQL SELECT ID, NAME, AMOUNT,DATE
FROM CUSTOMER
LEFT JOIN ORDER
11
Lecture Notes for DBMS

ON CUSTOMER.ID = ORDER.CUSTOMER_ID;

2. Right Outer Join: This join returns all the rows from right table are combined with the matching
rows of left table .If you get no column matching in the left table .it returns null value. It is also known
as right join Syntax:
SELECT table1.column1, table2.column2....
FROM table1
RIGHT JOIN table2
ON table1.column_field = table2.column_field; Ex:
SQL SELECT ID, NAME, AMOUNT,DATE
FROM CUSTOMER
RIGHT JOIN ORDER
ON CUSTOMER.ID = ORDER.CUSTOMER_ID;

COMPLEX INTEGRITY CONSTRAINTS IN SQL: Integrity constraints are a set of


rules used to maintain the quality of information. Integrity constraints ensure that the data insertion,
updating, and accessing have to be performed in such a way that data integrity is not affected and data
is not lost.

Types of Integrity Constraint:


1. Domain Constraints
2. Entity Integrity Constraints
3. Key Constraints
4. Referential Integrity Constraint

1) Domain constraints: Domain constraints can be defined as the definition of a valid set of values
for an attribute. The value of the attribute must be available in the corresponding domain.
Example:
SNo SName Age MobileNo
101 Ravi 20 9966012345
102 Rani 21 9848012345
103 Raju 19 9849012345
104 Ramu A 9963012345
105 Rajesh 19 9866012345

Not Allowed, as Age is an integer attribute (For SNo 104, Age is not an integer).
12
Lecture Notes for DBMS

2) Entity integrity constraints: The entity integrity constraint states that primary key value can't be
null. This is because the primary key value is used to identify individual rows in relation and if the
primary key has a null value, then we can't identify those rows. A table can contain a null value other
than the primary key field.
Example:
SNo SName Age MobileNo
101 Ravi 20 9966012345
102 Rani 21 9848012345
Raju 19 9849012345
104 Ramu A 9963012345
105 Rajesh 19 9866012345

Not Allowed, as Primary key (SNo) can not contain a NULL value.

3) Key constraints: Keys are used to uniquely identify records of a relation. A relation can have
multiple keys, but out of which one key will be the primary key.
Example:
SNo SName Age MobileNo
101 Ravi 20 9966012345
102 Rani 21 9848012345
103 Raju 19 9849012345
102 Ramu A 9963012345
105 Rajesh 19 9866012345

Not Allowed, as Primary key (SNo) does not contain UNIQUE values.

4) Referential Integrity Constraints: A referential integrity constraint is specified between two


tables. In the Referential integrity constraints, if a foreign key in Table 1 refers to the Primary Key
of Table 2, then every value of the Foreign Key in Table 1 must be null or be available in Table 2.

13
Lecture Notes for DBMS

ENFORCING INTEGRITY CONSTRAINTS: Constraints on a Single Relation are:


1. Not Null
2. Unique
3. Primary Key
4. Check (P ), where P is a predicate
5. Default
6. Referential Integrity

1. Not Null Constraint: Does not allow NULL values in attributes.


Ex: Declare name and budget to be NOT NULL
Create table customer (id number (5), name varchar (20) NOT NULL, budget number (12, 2) NOT
NULL);

2. Unique Constraint: unique ( A1, A2, …, Am)


The unique specification states that the attributes A1, A2, … Am form a unique/candidate key. Note:
Unique keys are permitted to be null (in contrast to primary keys).

3. Primary key: Both unique and not null Ex: dept_name vachar(20) primary key;
or
primary key (dept_name);

4. Check clause: The check clause permits domain values to be restricted with user specific
constraints/conditions.
14
Lecture Notes for DBMS

Syntax: check (P), where P is a predicate


Ex: ensure that semester is one of fall, winter, spring or summer:
create table section ( course_id varchar (8), sec_id varchar (8), semester varchar (6), year number (4),
primary key (course_id, sec_id, semester, year), check (semester in (’Fall’, ’Winter’, ’Spring’,
’Summer’)));

5. Default: SQL allows a default value to be specified for an attribute as illustrated by the following
create table statement:
create table student (ID number (5), name varchar (20) not null, deptname varchar (20), totcred number
(3) default 0, primary key (ID));

The default value of the totcred attribute is declared to be 0. As a result, when a tuple is inserted into the
student relation, if no value is provided for the totcred attribute, its value is set to 0. The following insert
statement illustrates how an insertion can omit the value for the tot cred attribute. insert into student(ID,
name, deptname) values (’12789’, ’Newman’, ’Comp. Sci.’);
6. Referential Integrity: Referential Integrity rule in DBMS is based on Primary and Foreign Key.
The Rule defines that a foreign key have a matching primary key. Reference from a table to another
table should be valid. For example, the dept_name in the Course table has a matching valid
dept_name in the Department table.
Ex: Create table Course (course_id varchar (8), course_name varchar (25), dept_name varchar (20),
credits number (3) check (credits > 0), primary key (course_id), foreign key (dept_name) references
department)

Triggers: A trigger is a procedure which is automatically invoked by the DBMS in response to


changes to the database, and is specified by the database administrator (DBA).

Parts of Trigger: A triggers description contains three parts. They are:


• Event − An event is a change to the database which activates the trigger.
• Condition − A query that is run when the trigger is activated is called as a condition.
• Action −A procedure which is executed when the trigger is activated and its condition is true.

Create Database Trigger: To create a database trigger, we use the CREATE TRIGGER command.
Syntax:
Create [Or Replace] TRIGGER Trigger_name

15
Lecture Notes for DBMS

{Before|After}
{Delete|Insert|Update[Of Columns]} On Table
[For Each Row {When Condition]]
[Reference [Old As Old] [New As New]]
Begin
Pl/Sql Block
End.

Use of Trigger:
• Trigger is used to perform automatic action when another concerned action takes place.
• To implement any complex business rule, that cannot be implemented using integrity constraints.
• Triggers will be used to audit the process i.e., to keep track of changes made to a table.

Active Databases: Database with a set of associated triggers is generally called an active database.
The databases which are regularly accessed and queried are usually referred to as active databases.

ADVANCED TOPICS

PARALLEL DATABASE: A parallel database involves multiple processors working in parallel


on the database used to provide the services. A parallel database system seeks to improve performance
through parallelization of various operations like loading data, building index and evaluating queries.
✓ Parallel systems improve processing and I/O speeds by using multiple CPU’s and disks in parallel.

Key Aspects of Parallel Database:


• Parallel processing divides a large task into many smaller tasks and executes the smaller tasks
concurrently on several CPU’s and completes it more quickly.
• The driving force behind parallel database systems is the demand of applications that have to
query extremely large databases of the order of terabytes or that have to process a large number
of transactions per second.
• In parallel processing, many operations are performed simultaneously as opposed to serial
processing, in which the computational steps are performed sequentially.
16
Lecture Notes for DBMS

Working of Parallel Database: Parallel database work as shown below:

Fig: Parallel Database

Advantages of Parallel Database:


1. Speed: Speed is the main advantage of parallel databases. It speeds up most requests for data so
that large databases can be reached more easily. Response time is also reduced.
2. Capacity: As more users request access to the database, the network administrators are adding
more machines to the parallel server, increasing their overall capacity.
3. Reliability: Despite the failure of any computer in the cluster, a properly configured parallel
database will continue to work. The database server senses that there is no response from a single
computer and redirects its function to the other computers.
4. Throughput: It is the number of tasks that can be completed in a given time interval. Parallel
Databases improve throughput by processing many transactions in parallel.
5. Benefits various types of queries for easy data retrieval

Many companies, such as online retailers, want their database to be accessible as fast as possible. This
is where a parallel database stands good.
17
Lecture Notes for DBMS

MULTIMEDIA DATABASE: The multimedia databases are used to store multimedia data
such as images, animation, audio, video along with text. This data is stored in the form of multiple file
types like .txt (text), .jpg (images), .swf (videos), .mp3 (audio) etc.

Fig: Types of Multimedia


Contents of the Multimedia Database: The multimedia database stores the multimedia data and
information related to it. The Contents include:
• Media Data: This is the multimedia data that is stored in the database such as images, videos,
audios, animation etc.
• Media Keyword Data: This contains the keyword data related to the media in the database. For
an image the keyword data can be date and time of the image, description of the image etc.
• Media Feature Data: The Media feature data describes the features of the media data. For an
image, feature data can be colors of the image, textures in the image etc.
• Media Format Data: The Media format data contains the formatting information related to the
media data such as sampling rate, frame rate, encoding scheme etc.

Challenges of Multimedia Database


1. It is difficult to convert one type of data format to another.
2. The multimedia database requires a large memory size.
3. It takes a lot of time to process multimedia data, so multimedia database is slow.

18
Lecture Notes for DBMS

MOBILE DATABASE: The data in a database can be accessed from anywhere using a mobile
database. It provides wireless database access.. Mobile databases are separate from the main database
and can easily be transported to various places. Even though they are not connected to the main database,
they can still communicate with the database to share and exchange data.

The mobile database includes the following components:


• The main system database that stores all the data and is linked to the mobile database.
• The mobile database that allows users to view information even while on the move. It shares
information with the main database.
• The device that uses the mobile database to access data. This device can be a mobile phone,
laptop etc.
• A communication link that allows the transfer of data between the mobile database and the main
database.

Advantages of Mobile Databases: Some advantages of mobile databases are:


• Multiple users can access the data with seamless delivery process.
• Mobile databases require very little support and maintenance.
• The mobile database can be synchronized with multiple devices such as mobiles, computer
devices, laptops etc.

Disadvantages of Mobile Databases: Some disadvantages of mobile databases are:


• The mobile data is less secure than data that is stored in a conventional stationary database.
• The mobile unit that houses a mobile database may frequently lose power because of limited
battery.
WEB DATABASE: A web database is a database that can be accessed from a local network or the
internet. These are hosted on websites, used for both professional and personal use. One of the familiar
types of web databases is a relational database, used for online shopping.

Typing in keywords such as “Pink Dress” enables all the Pink Dresses stored on the website to appear
right on the very browser you are looking on, because the information “Pink” and “Dress” are stored in
their database entries.
Some advantages of using a web database include:
1. The information is accessible from almost any device.
2. Web database programs usually come with their own technical support

19
Lecture Notes for DBMS

3. It’s convenient: web databases allow users to update information so all you have to do is to create
simple web forms.

MULTIDIMENSIONAL DATABASE: Multidimensional databases are used mostly for


OLAP (online analytical processing) and data warehousing. They can be used to show multiple
dimensions of data to users.

A multidimensional database is created from multiple relational databases. While relational databases
allow users to access data in the form of queries, the multidimensional databases allow users to ask
analytical questions related to business or market trends.

The multidimensional databases use MOLAP (multidimensional online analytical processing) to access
its data. They allow the users to quickly get answers to their requests by generating and analysing the
data rather quickly.

The data in multidimensional databases is stored in a data cube format. This means that data can be seen
and understood from many dimensions and perspectives.

Example:

Fig: Multidimensional Database


The revenue costs for a company can be understood and analyzed on the basis of various factors like the
company products, the geographical locations of the company offices, time to develop a product,
promotions done etc.

Advantages of Multidimensional Databases:


20
Lecture Notes for DBMS

1. Increased Performance: The performance of the multidimensional databases is much superior to


that of normal databases such as relational database.
2. Easy Maintenance: The multidimensional database is easy to handle and maintain
3. Better Data Presentation: The data in a multidimensional database is multi faceted and contains
many different factors. Hence, the data presentation is far superior to conventional databases.

Disadvantages of Multidimensional Databases: It is quite complex and it takes professionals to truly


understand and analyse the data in the database.

DATA WAREHOUSE: A Data Warehouse (DW) is a relational database that is designed for query
and analysis rather than transaction processing. A Data Warehouse provides integrated, enterprise-wide,
historical data and focuses on providing support for decision-makers for data modeling and analysis.

✓ Data Warehouse can be described as a centralized data repository which can be queried for business
benefits..
✓ Data Warehouse is not used for daily operations and transaction processing but used for making
decisions.

Data Warehouse environment contains an extraction, transportation, and loading (ETL) solution, an
online analytical processing (OLAP) engine, customer analysis tools, and other applications that handle
the process of gathering information and delivering it to business users.

Characteristics of Data Warehouse:


1. Subject-Oriented: A data warehouse target on the modeling and analysis of data for
decisionmakers. So, data warehouses typically provide a concise and straightforward view around a
particular subject, such as customer, product, or sales. This is done by excluding data that are not
useful concerning the subject and including all data needed by the users to understand the subject.
2. Integrated: A data warehouse integrates various heterogeneous data sources like RDBMS, flat files,
and online transaction records.
3. Time-Variant: Historical information is kept in a data warehouse. For example, one can retrieve
files from 3 months, 6 months, 12 months, or even previous data from a data warehouse.
4. Non-Volatile: The operational updates (update, insert, and delete operations) of data do not occur
in the data warehouse. It usually requires only two procedures in data accessing: Initial loading of
data and access to data. Therefore, the DW contains non-volatile data.

21
Lecture Notes for DBMS

Architecture of Data Warehouse: Data Warehousing involves data cleaning, data integration,
and data consolidations. A Data Warehouse has a 3-layer architecture:
1. Data Source Layer: It defines how the data comes to a Data Warehouse. It involves various data
sources and operational transaction systems, flat files, applications, etc.
2. Integration Layer: It consists of Operational Data Store and Staging area. Staging area is used to
perform data cleaning, data transformation and loading data from different sources to a data
warehouse. As multiple data sources are available for extraction at different time zones, staging area
is used to store the data and later to apply transformations on data.
3. Presentation Layer: This is used to perform BI reporting by end users. The data in a DW system is
accessed by BI users and used for reporting and analysis.

Fig: Data Warehouse Architecture

Data mart focuses on a single functional area and represents the simplest form of a Data Warehouse.
Consider a Data Warehouse that contains data for Sales, Marketing, HR, and Finance. A Data mart
focuses on a single functional area like Sales or Marketing.

Advantages of Data Warehouse


1. Understand business trends and make better forecasting decisions.
2. Data warehousing is an efficient method to manage demand for lots of information from lots of
users.
3. Queries that would be complex in many normalized databases could be easier to build and
maintain in data warehouses.
4. Data warehousing provide the capabilities to analyze a large amount of historical data.

OLTP Vs OLAP
OLTP: OLTP stands for On-Line Transactional Processing. It is featured by a large number of short
on-line transactions (INSERT, UPDATE, and DELETE). It is used for maintaining the online
22
Lecture Notes for DBMS

transaction and record integrity in multiple access environments. OLTP is a system that manages very
large number of short online transactions for example, ATM.

OLAP: OLAP stands for On-Line Analytical Processing. It is used for analysis of database information
from multiple database systems at one time such as sales analysis and forecasting, market research,
budgeting and etc. It is represented by a relatively low volume of transactions. Queries are very difficult
and involve aggregations. Data Warehouse is the example of OLAP system.

Differences between OLTP and OLAP:


Feature OLTP OLAP
1 Database Type It uses traditional DBMS It uses data warehouse
2 Data OLTP systems usually deal only OLAP systems needed historical data
with the current status of data for proper analysis and
decision making
3 Users Accessed by thousands of workers accessed only by a select class of few
/ clients in a huge decision-makers
enterprise
4 Functions OLTP manage day-to-day OLAP support the decision making
operations of an enterprise. operations.
5 Design OLTP database operations are OLAP operations are designed to be
designed to be subject-oriented
applicationoriented
6 Data It is mainly used for data reading It manages all insert, update and
Modification delete transaction
7 Response time In Milliseconds Processing is little slow
8 Normalization Tables in OLTP database are Tables in OLAP database are not
normalized. normalized.

The biggest difference between an OLTP and OLAP is the amount of data analyzed in a single
transaction. OLTP handles many concurrent customers and queries touching limited collection of
records at a time, whereas an OLAP system must have the efficiency to operate on millions of data to
answer a single query.

23
Lecture Notes for DBMS

NoSQL DATABASE: NoSQL Database is used to refer a non-SQL or non relational database. It
provides a mechanism for storage and retrieval of data other than tabular relations used in relational
databases. It is generally used to store big data and real-time web applications. Es: MongoDB.

Advantages of NoSQL
1. It can store and retrieve large amounts of data.
2. It supports query language.
3. It provides fast performance.

24

You might also like