Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 41

Faculty of Engineering &Technology

Subject Name : DBMS


Subject Code : 203105251
B.Tech :CSE, Year : 2, Semester : 4

Annexure No:
CASE STUDY

DATABASE MANAGEMENT
SYSTEM(203105251)
4TH SEMESTER
COMPUTER SCIENCE DEPARTMENT

1
Faculty of Engineering &Technology
Subject Name : DBMS
Subject Code : 203105251
B.Tech :CSE, Year : 2, Semester : 4

Annexure No:

TABLE OF CONTENTS

1. IBM DB2

 Introduction
 Structure
 Components
Features & Funtionalities

 Drawbacks
 Tools
 Real life example
2. MS SQL
 Components
 Features &Functionalities
 Structure
 Introduction
 Drawbacks
 Tools
 Real life example
3. MY SQL
 Introduction
 Structure
 Components
 Features &Functionalities
 Drawbacks
 Real life example
4. PL/SQL
 Introduction
 Structure
 Components
 Features &Functionalities
 Drawbacks
 Reallife example

2
Faculty of Engineering &Technology
Subject Name : DBMS
Subject Code : 203105251
B.Tech :CSE, Year : 2, Semester : 4

Annexure No:

The first topic on which we are going to do the case


study is IBM DB2 :

Introduction :
Db2 is a family of data management products, including database
servers, developed by IBM. They initially supported the relational
model, but were extended to support object-relational features and
non-relational structures like JSON and XML. The brand name was
originally styled as DB/2, then DB2 until 2017 and finally changed to
its present form.
When IBM released its first relational-database product, they wanted
to have a commercial-quality sublanguage as well, so it overhauled
SEQUEL, and renamed the revised language Structured Query
Language (SQL) to differentiate it from SEQUEL and also because
the acronym "SEQUEL" was a trademark of the UK-based Hawker
Siddeley aircraft company.
IBM bought Metaphor Computer Systems to utilize their GUI
interface and encapsulating SQL platform that had already been in use
since the mid 80's.
In parallel with the development of SQL, IBM also developed Query
by Example (QBE), the first graphical query language.

Structure :
SQLMA_DB2
3
Faculty of Engineering &Technology
Subject Name : DBMS
Subject Code : 203105251
B.Tech :CSE, Year : 2, Semester : 4

Annexure No:
Instance related information.
SQLMA_DBASE
Database related information for a particular database. If you use
the SQLMA_DBASE value, you must provide the database name in the
object parameter of sqlm_obj_struct structure.
SQLMA_APPL
Application information for an application that matches the provided
application ID. If you use the SQLMA_APPL value, you must provide an
application ID in the object parameter of sqlm_obj_struct structure.
SQLMA_AGENT_ID
Application information for an application that matches the provided agent
ID. If you use the SQLMA_AGENT_ID value, you must provide an agent
ID in the agent_id parameter of sqlm_obj_struct structure.
SQLMA_DBASE_TABLES
Table information for a particular database. If you use
the SQLMA_DBASE_TABLES value, you must provide the database name
in the object parameter of sqlm_obj_struct structure.
SQLMA_DBASE_APPLS
Application information for all applications connected to a particular
database. If you use the SQLMA_DBASE_APPLS value, you must provide
the database name in the object parameter of sqlm_obj_struct structure.
SQLMA_DBASE_APPLINFO
Summary application information for connections to a particular database. If
you use the SQLMA_DBASE_APPLINFO value, you must provide the
database name in the object parameter of sqlm_obj_struct structure.
SQLMA_DBASE_LOCKS
List of locks held on a particular database. If you use
the SQLMA_DBASE_LOCKS value, you must provide the database name
in the object parameter of sqlm_obj_struct structure.

SQLMA_APPL_LOCKS

4
Faculty of Engineering &Technology
Subject Name : DBMS
Subject Code : 203105251
B.Tech :CSE, Year : 2, Semester : 4

Annexure No:
List of locks held by an application with the matching application ID. If you
use the SQLMA_APPL_LOCKS value, you must provide an application ID
in the object parameter of sqlm_obj_struct structure.
SQLMA_APPL_LOCKS_AGENT_ID
List of locks held by an application with the matching agent ID. If you use
the SQLMA_APPL_LOCKS_AGENT_ID value, you must provide an agent
ID in the agent_id parameter of sqlm_obj_struct structure.
SQLMA_DBASE_ALL
Database information for all active databases in the instance.
SQLMA_APPL_ALL
Application information for all database connections in the instance.
SQLMA_APPLINFO_ALL
Summary application information for all connections to the instance.
SQLMA_DCS_APPLINFO_ALL
List of Database Connection Services (DCS) connections to the instance.
SQLMA_DYNAMIC_SQL
Dynamic SQL statement information for a particular database. If you use
the SQLMA_DYNAMIC_SQL value, you must provide the database name
in the object parameter of sqlm_obj_struct structure.
SQLMA_DCS_DBASE
Information for a particular Database Connection Services (DCS) database.
If you use the SQLMA_DCS_DBASE value, you must provide the database
name in the object parameter of sqlm_obj_struct structure.
SQLMA_DCS_DBASE_ALL
Information for all active Database Connection Services (DCS) databases.

SQLMA_DCS_APPL_ALL
Database Connection Services (DCS) application information for all
connections.
SQLMA_DCS_APPL
Database Connection Services (DCS) application information for an
application that matches the provided application ID. If you use

5
Faculty of Engineering &Technology
Subject Name : DBMS
Subject Code : 203105251
B.Tech :CSE, Year : 2, Semester : 4

Annexure No:
the SQLMA_DCS_APPL value, you must provide an application ID in the
object parameter of sqlm_obj_struct structure.
SQLMA_DCS_APPL_HANDLE
Database Connection Services (DCS) application information for an
application that matches the provided agent ID. If you use
the SQLMA_DCS_APPL_HANDLE value, you must provide an agent ID
in the agent_id parameter of sqlm_obj_struct structure.
SQLMA_DCS_DBASE_APPLS
Database Connection Services (DCS) application information for all active
connections to a particular database. If you use
the SQLMA_DCS_DBASE_APPLS value, you must provide the database
name in the object parameter of sqlm_obj_struct structure.
SQLMA_DBASE_TABLESPACES
Table space information for a particular database. If you use
the SQLMA_DBASE_TABLESPACES value, you must provide the
database name in the object parameter of sqlm_obj_struct structure.
SQLMA_DBASE_BUFFERPOOLS
Bufferpool information for a particular database. If you use
the SQLMA_DBASE_BUFFERPOOLS value, you must provide the
database name in the object parameter of sqlm_obj_struct structure.
SQLMA_BUFFERPOOLS_ALL
Information for all bufferpools.
SQLMA_DBASE_REMOTE
Remote access information for a particular federated database. If you use
the SQLMA_DBASE_REMOTE value, you must provide the database
name in the object parameter of sqlm_obj_struct structure.
SQLMA_DBASE_REMOTE_ALL
Remote access information for all federated databases.

COMPONENTS:

The two primary types of storage structures in DB2  are table spaces and index
spaces.

6
Faculty of Engineering &Technology
Subject Name : DBMS
Subject Code : 203105251
B.Tech :CSE, Year : 2, Semester : 4

Annexure No:
DB2 databases
DB2 databases are a set of DB2 structures that include a collection of tables,
their associated indexes, and the table spaces in which they reside. You define a
database by using the CREATE DATABASE statement.
DB2 table spaces
A DB2 table space is a set of volumes on disks that hold the data sets in which
tables are actually stored. Every table is stored in table space.
DB2 index spaces
An index space is a DB2 storage structure that contains a single index.

DB2 hash spaces


A hash space is a defined disk space that organizes table data for hash access.
DB2 storage groups
DB2 storage groups are a set of volumes on disks that hold the data sets in
which tables and indexes are stored.

A routine is an executable SQL object. The two types of routines are


functions and stored procedures.
Functions
A function is a routine that can be invoked from within other SQL
statements and that returns a value or a table.
Procedures
A procedure, also known as a stored procedure, is a routine that you
can call to perform operations that can include SQL statements.
The 4 major components of DB2 mainframe are:
System services component, which supports system operation,
operator communication, logging and similar functions.
Locking services component, which provides the necessary controls
for managing concurrent access to data.
Database services component, which supports the definition, retrieval
and update of user and system data.
Distributed data facility component, which provides DB2's,
distributed database support.
Features :
1) Storage optimization
2) IBM pureScale
7
Faculty of Engineering &Technology
Subject Name : DBMS
Subject Code : 203105251
B.Tech :CSE, Year : 2, Semester : 4

Annexure No:
3) SQL compatibility
4) Advanced storage optimization
5) Disaster Recovery
Hybrid Flex

FUNCTIONALITIES:
The following table shows DB2 server editions and their features:

Editions Features

Advanced Enterprise It is designed for mid-size to large-size business organizations. Platform -


Server Edition and Linux, UNIX, and Windows. Table partitioning High Availability Disaster
Enterprise Server Edition Recovery (HARD) Materialized Query Table (MQTs) Multidimensional
(AESE / ESE) Clustering (MDC) Connection concentrator Pure XML Backup compression
Homogeneous Federations

Workgroup Server Edition It is designed for Workgroup or mid-size business organizations. Using this
(WSE) WSE you can work with - High Availability Disaster Recovery (HARD)
Online Reorganization Pure XML Web Service Federation support DB2
Homogeneous Federations Homogeneous SQL replication Backup
compression

Express -C It provides all the capabilities of DB2 at zero charge. It can run on any physical
or virtual systems with any size of configuration.

Express Edition It is designed for entry level and mid-size business organizations. It is full
featured DB2 data server. It offers only limited services. This Edition comes
with - Web Service Federations DB2 homogeneous federations Homogeneous
SQL Replications Backup compression

Enterprise Developer It offers only single application developer. It is useful to design, build and
Edition prototype the applications for deployment on any of the IBM server. The

8
Faculty of Engineering &Technology
Subject Name : DBMS
Subject Code : 203105251
B.Tech :CSE, Year : 2, Semester : 4

Annexure No:
software cannot be used for developing applications.

DB2 has a comprehensive infrastructure that enables it to provide data integrity, performance,


and the ability to recover user data.
A. DB2 catalog
B. DB2 directory
C. Active and archive logs
D. Bootstrap data set
E. Buffer pools
F. Data definition control support database
G. The resource limit facility
H. Work file database
I. Application processes and transactions
Subsystem parameters

Tools :
1) IBM DB2 Augmented Dta Explorer
2) IBM DB2 Connect
3) IBM Data Studio
4) IBM Lift
5) IBM DB2 tools for z/OS.
9
Faculty of Engineering &Technology
Subject Name : DBMS
Subject Code : 203105251
B.Tech :CSE, Year : 2, Semester : 4

Annexure No:

Advantages :

1 Query performance can be improved by running in parallel (pieces of


the query are run simultaneously on different systems).

2 The need for data replication decreases because all of the systems can
access all of the data.

3 Much larger database files can be accommodated.

4 Applications are no longer concerned with the location of remote data.

5 When growth is needed, you can redistribute the file across more
systems, and applications can run unchanged on the new systems.
With DB2 Multisystem, you can use the same input/output (I/O) methods (GETs,
PUTs, and UPDATEs) or file access methods that you have used in the past. No
additional or different I/O methods or file access methods are required.

Real Life Examples :


1) Improved Global operations, synchronized supply chains
10
Faculty of Engineering &Technology
Subject Name : DBMS
Subject Code : 203105251
B.Tech :CSE, Year : 2, Semester : 4

Annexure No:
2) Quicker and more reliable claims processing
3) Reducing downtime and refining operations to supply a
community of millions with clean water
4) Simplified IT to deliver “everywhere and always on” customer
service.

11
Faculty of Engineering &Technology
Subject Name : DBMS
Subject Code : 203105251
B.Tech :CSE, Year : 2, Semester : 4

Annexure No:
The second topic of our case study is MS SQL:

Introduction :
MS SQL Server is a relational database management system (RDBMS)
developed by Microsoft. This product is built for the basic function of storing
retrieving data as required by other applications. It can be run either on the same
computer or on another across a network. This tutorial explains some basic and
advanced concepts of SQL Server such as how to create and restore data, create
login and backup, assign permissions, etc. Each topic is explained using
examples for easy understanding.

Structure :

SYSTEM Displays virtual systems tables and other metaschema tables. These tables cannot be altered.
TABLE

TABLE Displays all application tables. Table nodes expand to show columns, indexes, and
triggers.When you select a table name, data and meta-data appear in the DB Details view.
Note: Since tables are displayed in ASCII order and sorting is case-sensitive, all lowercase
table names sort after the uppercase table names.

VIEW Displays the names of all created views.

PROCEDURE Displays all procedures that are stored in the database and available for reuse.

12
Faculty of Engineering &Technology
Subject Name : DBMS
Subject Code : 203105251
B.Tech :CSE, Year : 2, Semester : 4

Annexure No:

TRIGGER Displays all triggers, which execute in response to a predefined event or activity.

FUNCTIONS Displays all functions, or pieces of a program that you can use separately from the remainder
of the program.

SESSIONS Displays the session information for the current catalog.

Components:

 Database Engine: This part of SQL Server actually creates and drives


relational databases.
 SQL Server Analysis Services (SSAS): SSAS is the data-analysis
component of SQL Server. It can create OLAP (OnLine Analytical
Processing) cubes — sophisticated programming objects for organizing
data inside a relational database — and do data mining (pulling
relevant data out of a database in response to an ad-hoc question).
 SQL Server Reporting Services (SSRS): SSRS is a component of
SQL Server that provides reporting regardless of a database’s operating
system.
 SQL Server Integration Services (SSIS): SSIS is a component of
SQL Server that does the Extract, Transform, and Load (ETL) process
that cleans up and formats raw data from source systems for inclusion
in the database as ready-to-use information.

FEATURES:
1)To create databases.

2)To maintain databases.

13
Faculty of Engineering &Technology
Subject Name : DBMS
Subject Code : 203105251
B.Tech :CSE, Year : 2, Semester : 4

Annexure No:
3)To analyze the data through SQL Server Analysis Services (SSAS).

4)To generate reports through SQL Server Reporting Services (SSRS).

5)To carry out ETL operations through SQL Server Integration Services (SSIS)

Function category Description


Configuration Functions Return information about the current configuration.
Conversion Functions Support data type casting and converting.
Cursor Functions Return information about cursors.
Date and Time Data Types and Perform operations on a date and time input values and return string,
Functions numeric, or date and time values.
JSON Functions Validate, query, or change JSON data.
Logical Functions Perform logical operations.
Mathematical Functions Perform calculations based on input values provided as parameters to the
functions, and return numeric values.
Metadata Functions Return information about the database and database objects.
Security Functions Return information about users and roles.
String Functions Perform operations on a string (char or varchar) input value and return a
string or numeric value.
System Functions Perform operations and return information about values, objects, and settings
in an instance of SQL Server.
System Statistical Functions Return statistical information about the system.
Text and Image Functions Perform operations on text or image input values or columns, and return
information about the value.

 MySQL doesn't support SQL check constraints.

TOOLS:

 MySQL Workbench. 
 phpMyAdmin.
 HeidiSQL.
 Toad Edge.
 Navicat  
14
Faculty of Engineering &Technology
Subject Name : DBMS
Subject Code : 203105251
B.Tech :CSE, Year : 2, Semester : 4

Annexure No:

REAL LIFE EXAMPLE:

Many programming languages with language-specific APIs include libraries for accessing


MySQL databases. These include MySQL Connector/Net for integration with
Microsoft's Visual Studio (languages such as C# and VB are most commonly used) and the
JDBC driver for Java. In addition, an ODBC interface called MySQL
Connector/ODBC allows additional programming languages that support the ODBC interface
to communicate with a MySQL database, such as ASP or ColdFusion. The HTSQL – URL-
based query method also ships with a MySQL adapter, allowing direct interaction between a
MySQL database and any web client via structured URLs. Other drivers exists for languages
like Pythonor Node.js.

15
Faculty of Engineering &Technology
Subject Name : DBMS
Subject Code : 203105251
B.Tech :CSE, Year : 2, Semester : 4

Annexure No:

MS SQL
INTRODUCTION:

Microsoft SQL Server is a relational database management system developed


by Microsoft. As a database server, it is a software product with the primary
function of storing and retrieving data as requested by other software
applications—which may run either on the same computer or on another
computer across a network (including the Internet).
Microsoft markets at least a dozen different editions of Microsoft SQL Server,
aimed at different audiences and for workloads ranging from small single-
machine applications to large Internet-facing applications with many concurrent
users

Introduction :
MySQL is a fast, easy-to-use RDBMS being used for many small
and big businesses. MySQL is developed, marketed and supported by
MySQL AB, which is a Swedish company. MySQL is becoming so
popular because of many good reasons −
 MySQL is released under an open-source license. So you have
nothing to pay to use it.
 MySQL is a very powerful program in its own right. It handles
a large subset of the functionality of the most expensive and
powerful database packages.
16
Faculty of Engineering &Technology
Subject Name : DBMS
Subject Code : 203105251
B.Tech :CSE, Year : 2, Semester : 4

Annexure No:
 MySQL uses a standard form of the well-known SQL data
language.
 MySQL works on many operating systems and with many
languages including PHP, PERL, C, C++, JAVA, etc.
 MySQL works very quickly and works well even with large
data sets.
 MySQL is very friendly to PHP, the most appreciated language
for web development.
 MySQL supports large databases, up to 50 million rows or more
in a table. The default file size limit for a table is 4GB, but you
can increase this (if your operating system can handle it) to a
theoretical limit of 8 million terabytes (TB).
 MySQL is customizable. The open-source GPL license allows
programmers to modify the MySQL software to fit their own
specific environments.

Structure :

Literal values (string, numbers etc.)

The terms literal refer to a fixed data value. MySQL evaluates seven types of
literal values numeric, character string, date and time, hexadecimal, boolean,
bit-field, and NULL Values

Numeric Literals

Numeric literal notation is used to specify fixed and floating-point numbers.


Floating-point numbers use '.' as a decimal separator. Both types of numbers
may be preceded by '+' or '-' to indicate a positive or negative numbers. You

17
Faculty of Engineering &Technology
Subject Name : DBMS
Subject Code : 203105251
B.Tech :CSE, Year : 2, Semester : 4

Annexure No:
can use the integer notation in expressions, conditions, SQL functions, and
SQL statements. The examples of integer is as follows :

Valid integers :

 0

 1254

 -256

Valid floating-point numbers :

 132.45

 12.00

 -21032.6309e+10

Components features and functionality :


Components:

18
Faculty of Engineering &Technology
Subject Name : DBMS
Subject Code : 203105251
B.Tech :CSE, Year : 2, Semester : 4

Annexure No:

 MySQL Server. It is the database server. ...


 MySQL Clients. These are programs that communicate with the server.
 Data Directory. This is where MySQL stores the databases.
 Storage Engine. Manages how the information is organised, stored and
accessed.

Features :

19
Faculty of Engineering &Technology
Subject Name : DBMS
Subject Code : 203105251
B.Tech :CSE, Year : 2, Semester : 4

Annexure No:

Functionality:

5.1MySQL String Functions

Function Description

ASCII Returns the ASCII value for the specific character

20
Faculty of Engineering &Technology
Subject Name : DBMS
Subject Code : 203105251
B.Tech :CSE, Year : 2, Semester : 4

Annexure No:

CHAR_LENGTH Returns the length of a string (in characters)

CHARACTER_LENGTH Returns the length of a string (in characters)

CONCAT Adds two or more expressions together

CONCAT_WS Adds two or more expressions together with a separator

FIELD Returns the index position of a value in a list of values

FIND_IN_SET Returns the position of a string within a list of strings

FORMAT Formats a number to a format like "#,###,###.##", rounded


to a specified number of decimal places

INSERT Inserts a string within a string at the specified position and


for a certain number of characters

INSTR Returns the position of the first occurrence of a string in

21
Faculty of Engineering &Technology
Subject Name : DBMS
Subject Code : 203105251
B.Tech :CSE, Year : 2, Semester : 4

Annexure No:

another string

LCASE Converts a string to lower-case

LEFT Extracts a number of characters from a string (starting from


left)

LENGTH Returns the length of a string (in bytes)

LOCATE Returns the position of the first occurrence of a substring in


a string

LOWER Converts a string to lower-case

LPAD Left-pads a string with another string, to a certain length

LTRIM Removes leading spaces from a string

MID Extracts a substring from a string (starting at any position)

POSITION Returns the position of the first occurrence of a substring in

22
Faculty of Engineering &Technology
Subject Name : DBMS
Subject Code : 203105251
B.Tech :CSE, Year : 2, Semester : 4

Annexure No:

a string

REPEAT Repeats a string as many times as specified

REPLACE Replaces all occurrences of a substring within a string, with


a new substring

REVERSE Reverses a string and returns the result

RIGHT Extracts a number of characters from a string (starting from


right)

RPAD Right-pads a string with another string, to a certain length

RTRIM Removes trailing spaces from a string

SPACE Returns a string of the specified number of space


characters

STRCMP Compares two strings

23
Faculty of Engineering &Technology
Subject Name : DBMS
Subject Code : 203105251
B.Tech :CSE, Year : 2, Semester : 4

Annexure No:

SUBSTR Extracts a substring from a string (starting at any position)

SUBSTRING Extracts a substring from a string (starting at any position)

SUBSTRING_INDEX Returns a substring of a string before a specified number of


delimiter occurs

TRIM Removes leading and trailing spaces from a string

UCASE Converts a string to upper-case

UPPER Converts a string to upper-case

5.2MySQL Numeric Functions

Function Description

ABS Returns the absolute value of a number

24
Faculty of Engineering &Technology
Subject Name : DBMS
Subject Code : 203105251
B.Tech :CSE, Year : 2, Semester : 4

Annexure No:

ACOS Returns the arc cosine of a number

ASIN Returns the arc sine of a number

ATAN Returns the arc tangent of one or two numbers

ATAN2 Returns the arc tangent of two numbers

AVG Returns the average value of an expression

CEIL Returns the smallest integer value that is >= to a number

CEILING Returns the smallest integer value that is >= to a number

COS Returns the cosine of a number

COT Returns the cotangent of a number

25
Faculty of Engineering &Technology
Subject Name : DBMS
Subject Code : 203105251
B.Tech :CSE, Year : 2, Semester : 4

Annexure No:

COUNT Returns the number of records returned by a select query

DEGREES Converts a value in radians to degrees

DIV Used for integer division

EXP Returns e raised to the power of a specified number

FLOOR Returns the largest integer value that is <= to a number

GREATEST Returns the greatest value of the list of arguments

LEAST Returns the smallest value of the list of arguments

LN Returns the natural logarithm of a number

LOG Returns the natural logarithm of a number, or the logarithm


of a number to a specified base

LOG10 Returns the natural logarithm of a number to base 10

26
Faculty of Engineering &Technology
Subject Name : DBMS
Subject Code : 203105251
B.Tech :CSE, Year : 2, Semester : 4

Annexure No:

LOG2 Returns the natural logarithm of a number to base 2

MAX Returns the maximum value in a set of values

MIN Returns the minimum value in a set of values

MOD Returns the remainder of a number divided by another


number

PI Returns the value of PI

POW Returns the value of a number raised to the power of


another number

POWER Returns the value of a number raised to the power of


another number

RADIANS Converts a degree value into radians

RAND Returns a random number

27
Faculty of Engineering &Technology
Subject Name : DBMS
Subject Code : 203105251
B.Tech :CSE, Year : 2, Semester : 4

Annexure No:

ROUND Rounds a number to a specified number of decimal places

SIGN Returns the sign of a number

SIN Returns the sine of a number

SQRT Returns the square root of a number

SUM Calculates the sum of a set of values

TAN Returns the tangent of a number

TRUNCATE Truncates a number to the specified number of decimal


places

5.3MySQL Date Functions

Function Description

28
Faculty of Engineering &Technology
Subject Name : DBMS
Subject Code : 203105251
B.Tech :CSE, Year : 2, Semester : 4

Annexure No:

ADDDATE Adds a time/date interval to a date and then returns the date

ADDTIME Adds a time interval to a time/datetime and then returns the


time/datetime

CURDATE Returns the current date

CURRENT_DATE Returns the current date

CURRENT_TIME Returns the current time

CURRENT_TIMESTAMP Returns the current date and time

CURTIME Returns the current time

DATE Extracts the date part from a datetime expression

DATEDIFF Returns the number of days between two date values

DATE_ADD Adds a time/date interval to a date and then returns the date

29
Faculty of Engineering &Technology
Subject Name : DBMS
Subject Code : 203105251
B.Tech :CSE, Year : 2, Semester : 4

Annexure No:

DATE_FORMAT Formats a date

DATE_SUB Subtracts a time/date interval from a date and then returns


the date

DAY Returns the day of the month for a given date

DAYNAME Returns the weekday name for a given date

DAYOFMONTH Returns the day of the month for a given date

DAYOFWEEK Returns the weekday index for a given date

DAYOFYEAR Returns the day of the year for a given date

EXTRACT Extracts a part from a given date

FROM_DAYS Returns a date from a numeric datevalue

HOUR Returns the hour part for a given date

30
Faculty of Engineering &Technology
Subject Name : DBMS
Subject Code : 203105251
B.Tech :CSE, Year : 2, Semester : 4

Annexure No:

LAST_DAY Extracts the last day of the month for a given date

LOCALTIME Returns the current date and time

LOCALTIMESTAMP Returns the current date and time

MAKEDATE Creates and returns a date based on a year and a number of


days value

MAKETIME Creates and returns a time based on an hour, minute, and


second value

MICROSECOND Returns the microsecond part of a time/datetime

MINUTE Returns the minute part of a time/datetime

MONTH Returns the month part for a given date

MONTHNAME Returns the name of the month for a given date

NOW Returns the current date and time

31
Faculty of Engineering &Technology
Subject Name : DBMS
Subject Code : 203105251
B.Tech :CSE, Year : 2, Semester : 4

Annexure No:

PERIOD_ADD Adds a specified number of months to a period

PERIOD_DIFF Returns the difference between two periods

QUARTER Returns the quarter of the year for a given date value

SECOND Returns the seconds part of a time/datetime

SEC_TO_TIME Returns a time value based on the specified seconds

STR_TO_DATE Returns a date based on a string and a format

SUBDATE Subtracts a time/date interval from a date and then returns


the date

SUBTIME Subtracts a time interval from a datetime and then returns


the time/datetime

SYSDATE Returns the current date and time

32
Faculty of Engineering &Technology
Subject Name : DBMS
Subject Code : 203105251
B.Tech :CSE, Year : 2, Semester : 4

Annexure No:

TIME Extracts the time part from a given time/datetime

TIME_FORMAT Formats a time by a specified format

TIME_TO_SEC Converts a time value into seconds

TIMEDIFF Returns the difference between two time/datetime


expressions

TIMESTAMP Returns a datetime value based on a date or datetime value

TO_DAYS Returns the number of days between a date and date "0000-
00-00"

WEEK Returns the week number for a given date

WEEKDAY Returns the weekday number for a given date

WEEKOFYEAR Returns the week number for a given date

33
Faculty of Engineering &Technology
Subject Name : DBMS
Subject Code : 203105251
B.Tech :CSE, Year : 2, Semester : 4

Annexure No:

YEAR Returns the year part for a given date

YEARWEEK Returns the year and week number for a given date

5.4MySQL Advanced Functions

Function Description

BIN Returns a binary representation of a number

BINARY Converts a value to a binary string

CASE Goes through conditions and return a value when the first
condition is met

CAST Converts a value (of any type) into a specified datatype

34
Faculty of Engineering &Technology
Subject Name : DBMS
Subject Code : 203105251
B.Tech :CSE, Year : 2, Semester : 4

Annexure No:

COALESCE Returns the first non-null value in a list

CONNECTION_ID Returns the unique connection ID for the current


connection

CONV Converts a number from one numeric base system to


another

CONVERT Converts a value into the specified datatype or character set

CURRENT_USER Returns the user name and host name for the MySQL
account that the server used to authenticate the current
client

DATABASE Returns the name of the current database

IF Returns a value if a condition is TRUE, or another value if


a condition is FALSE

IFNULL Return a specified value if the expression is NULL,


otherwise return the expression

ISNULL Returns 1 or 0 depending on whether an expression is


35
Faculty of Engineering &Technology
Subject Name : DBMS
Subject Code : 203105251
B.Tech :CSE, Year : 2, Semester : 4

Annexure No:

NULL

LAST_INSERT_ID Returns the AUTO_INCREMENT id of the last row that


has been inserted or updated in a table

NULLIF Compares two expressions and returns NULL if they are


equal. Otherwise, the first expression is returned

SESSION_USER Returns the current MySQL user name and host name

SYSTEM_USER Returns the current MySQL user name and host name

USER Returns the current MySQL user name and host name

VERSION Returns the current version of the MySQL database

Tools :
1) Dbforge
2) MY SQL Workbench
3) Php MyAdmin
4) Heidi SQL
5) Toad Edge for MY SQL

36
Faculty of Engineering &Technology
Subject Name : DBMS
Subject Code : 203105251
B.Tech :CSE, Year : 2, Semester : 4

Annexure No:

Advantages :
 Data Security. ...
 On-Demand Scalability. ...
 High Performance. ...
 Round-the-clock Uptime. ...
 Comprehensive Transactional Support. ...
 Complete Workflow Control. ...
 Reduced Total Cost of Ownership. ...
 The Flexibility of Open Source.

Real Life Examples :

37
Faculty of Engineering &Technology
Subject Name : DBMS
Subject Code : 203105251
B.Tech :CSE, Year : 2, Semester : 4

Annexure No:
PL/SQL
INTRODUCTION:

 PL/SQL is an extension of Structured Query Language (SQL) that is used in Oracle.


Unlike SQL, PL/SQL allows the programmer to write code in a procedural format.
Full form of PL/SQL is "Procedural Language extensions to SQL".

 It combines the data manipulation power of SQL with the processing power of
procedural language to create super powerful SQL queries.

 PL/SQL means instructing the compiler 'what to do' through SQL and 'how to do'
through its procedural way.

 Similar to other database languages, it gives more control to the programmers by the
use of loops, conditions and object-oriented concepts.

STRUCTURE:

38
Faculty of Engineering &Technology
Subject Name : DBMS
Subject Code : 203105251
B.Tech :CSE, Year : 2, Semester : 4

Annexure No:
Figure 7 PL/SQL Architecture Diagram

Figure 8 Block structure of PL/SQL

COMPONENTS:

The PL/SQL architecture mainly consists of following three components:

1. PL/SQL block
2. PL/SQL Engine
3. Database Server

5.4.1 PL/SQL block:

 This is the component which has the actual PL/SQL code.


 This consists of different sections to divide the code logically (declarative section for
declaring purpose, execution section for processing statements, exception handling
section for handling errors)
 It also contains the SQL instruction that used to interact with the database server.

5.4.2 PL/SQL Engine:

 PL/SQL engine is the component where the actual processing of the codes takes
place.
 PL/SQL engine separates PL/SQL units and SQL part in the input (as shown in the
image below).
 The separated PL/SQL units will be handled by the PL/SQL engine itself.
39
Faculty of Engineering &Technology
Subject Name : DBMS
Subject Code : 203105251
B.Tech :CSE, Year : 2, Semester : 4

Annexure No:
 The SQL part will be sent to database server where the actual interaction with
database takes place.
 It can be installed in both database server and in the application server.

5.4.3 Database Server:

 This is the most important component of Pl/SQL unit which stores the data.
 The PL/SQL engine uses the SQL from PL/SQL units to interact with the database
server.
 It consists of SQL executor which parses the input SQL statements and execute the
same.

FEATURES& FUNCTIONALITIES:

 Better performance, as SQL is executed in bulk rather than a single statement


 High Productivity
 Tight integration with SQL
 Full Portability
 Tight Security
 Support Object Oriented Programming concepts.

DISADVANTAGES OF PL/SQL:
 Proprietary to Oracle
PL/SQL is proprietary to Oracle which means if you were to change database vendors
then you would have to re-write all your Oracle PL/SQL programs.
 Poor I/O Features
The other limitation of PL/SQL is that there is very little support for i/o either to
read/write files or to read from or write to a user interface. The rationale behind this is
that PLSQL is designed for manipulating information from the database and not for
processing files or communicating with users.

REAL LIFE EXAMPLE:


A simple example of PL/SQL would be using it to perform more complex math/update/insert
type functions. For example, if you want to run a logical IF/THEN/ELSE type scenario on an
employee you could see if their pay falls below a certain threshold, if it does then you
perform a math operation to determine what their new pay would need to be and then run an
update. This is just one simple example. PL/SQL is capable of some extremely complex
operations.

40
Faculty of Engineering &Technology
Subject Name : DBMS
Subject Code : 203105251
B.Tech :CSE, Year : 2, Semester : 4

Annexure No:

41

You might also like