Exam

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Query optimization is the process of selecting an efficient

execution plan for evaluating the query. After parsing the Big Data are high volume, high velocity, or high-variety
query, the parsed query is passed to the query optimizer, information assets that require new forms of processing to
which generates different execution plans to evaluate the enable enhanced decision making, insight discovery, and
parsed query and select the plan with least estimated cost. process optimization.
Catalogue manager helps the optimizer to choose the best Big data allows you to re-develop the products/services
plan to execute the query generating cost of each plan. you are selling. Information on what others think about
Query optimization is used for accessing the database in
your products -such as through unstructured social
an efficient manner. It is an art of obtaining desired
information in a predictable, reliable and timely manner. networking site text- helps you in product development.
Formally defines query optimization as a process of Big data allows you to test different variations of CAD
transforming a query into an equivalent form which can be
(computer-aided design) images to determine how minor
evaluated more efficiently. The essence of query
optimization is to find an execution plan that minimises changes affect your process or product. This makes big
time needed to evaluate a query. To achieve this data invaluable in the manufacturing process. Predictive
optimization goal, we need to accomplish two main tasks.
analysis will keep you ahead of your competitors. Big data
First one is to find out the best plan and the second one is
to reduce the time involved in executing the query plan. can facilitate this by, as an example, scanning and
analysing social media feeds and newspaper reports. Big
Three different phases during the query processing in data also helps you do health-tests on your customers,
DBMS which are as follows: Parsing and translation
Optimization Evaluation. Usually, user queries are suppliers, and other stakeholders to help you reduce risks
submitted to DBMS as SQL queries. During the parsing such as default. Big data allows you to diversify your
and translation phase, the given query is translated into its revenue streams. Analysing big data can give you
internal form. In generating the internal form of the query,
trend-data that could help you come up with a completely
the parser checks the syntax of the user's query, verifies
that the relation names appearing in the query are names new revenue stream.
of the relations in the database and so on. The system
constructs a parse tree representation of the query, which
it then translates into a relational algebra expression. A relational database is one that stores data in tables. The
For example let us consider the following SQL query:-
Select Sno from Student where Sno='101' relationship between each data point is clear and
This query is then translated into either of the following searching through those relationships is relatively easy.
relational algebra expressions as follows:- The relationship between tables and field types is called a
σSno = '101' (πSno ( Student )) πSno ( σSno='101'
schema. For relational databases, the schema must be
(Student)) After parsing and translation into relational
algebra expression, the query is then transformed into a clearly defined. A non-relational database is any
form which is usually a query tree or graph that can be database that does not use the tabular schema of rows
handled by the optimization engine. Query representation
and columns like in relational databases. Rather, its
During the optimization phase, the optimization engine
performs various analyses on the query data. It applies storage model is optimised for the type of data it’s storing.
various rules to the internal data structures of the query to
transform these structures into equivalent and efficient
representation. It then generates valid evaluation plans An explicit cursor is a named pointer to a private SQL
based upon the rules applied. From the generated
area that stores information for processing a specific query
evaluation plans, the best evaluation plan to be executed
is determined and passed onto the query execution or DML statement—typically, one that returns or affects
engine. The final phase in processing a query is the multiple rows. You can use an explicit cursor to retrieve
evaluation phase. During the evaluation phase, the best
the rows of a result set one at a time.
evaluation plan generated by the optimization engine is
selected and then executed.
The next step is an optimization step that transforms the
initial algebraic query using relational algebra
transformation into other algebraic queries until the best
one is found. A query execution plan is then found which,
represented as a query tree, includes information about
the access method available for each relation as well as
the algorithms used in computing the relational operations
in the tree. The next step is called code generator, where
we generate code for the selected query execution plan.
This code is then executed by the runtime database
processor to produce the query result. The runtime
database processor has the task of running the query
code, whether in compiled or interpreted mode, to produce
the query result. If a run time error results, an error
message is generated by the runtime database processor.
Before using an explicit cursor, you must declare and ​ AFTER DELETE ON EMPLOYEES
define it. You can either declare it first (with ​ FOR EACH ROW
​ BEGIN
cursor_declaration) and then define it later in the same
​ UPDATE TOTAL_EMPLOYEES SET
block, subprogram, or package (with cursor_definition) employee_count=employee_count-1;
or declare and define it at the same time (with ​ END;

cursor_definition). To open a cursor, use the following


The above simple trigger will reduce the employee_count
syntax: OPEN cursor_name [(argument [,argument ...])]; column of the TOTAL_EMPLOYEES table by 1
where cursor_name is the name of the cursor as declared automatically after a row is deleted from EMPLOYEES
in the declaration section. The arguments are required if table.

the definition of the cursor contains a parameter list. You


must open an explicit cursor before you can fetch rows Implicit cursors are
Explicit cursors need to be
automatically created
from that cursor. When the cursor is opened, the defined explicitly by the
when select statements
user by providing a name.
processing includes the PARSE, BIND, OPEN, and are executed.
Explicit cursors can fetch
They are capable of
EXECUTE statements. This OPEN processing includes: multiple rows.
fetching a single row at a
Need to close after
determining an execution plan, associating host variables time.
execution.
Closes automatically after
and cursor parameters with the placeholders in the SQL They are less vulnerable
execution.
to errors(Data errors etc.)
statement, determining the result set, and, finally, setting They are more vulnerable
User/Programmer has the
to errors such as Data
the current row pointer to the first row in the result set. entire control.
errors, etc.
Comparative to Implicit
When using a cursor FOR loop, the OPEN is implicit in the Provides less
cursors, explicit cursors
programmatic control to
FOR statement. If you try to open a cursor that is already are more efficient.
the users
Explicit cursors are
open, PL/SQL will raise an "ORA-06511: PL/SQL: cursor Implicit cursors are less
defined as:
efficient.
already open" exception. Implicit Cursors are
DECLARE
defined as:
CURSOR cur_name IS
Fetching from explicit cursors The FETCH statement SELECT attr_name from
BEGIN
places the contents of the current row into local variables. table_name
SELECT attr_name from
where CONDITION;
To retrieve all rows in a result set, each row needs to be table_name
BEGIN
where CONDITION;
fetched. The syntax for a FETCH statement is: FETCH END
cursor_name INTO record_or_variable_list; where
cursor_name is the name of the cursor as declared and
opened. Stands for
Relational
Database
Management Stands for Object
Closing explicit cursors The syntax of the CLOSE System. Oriented Database
Stores data in Management
statement is: CLOSE cursor_name; where cursor_name is Long
Entities, System.
Form
the name of the cursor declared and opened. After all defined as Stores data as
Way of
tables hold Objects.
rows have been fetched, a cursor needs to be closed. storing
specific Handles larger and
data
Closing a cursor releases the private SQL area used by information. complex data than
Data
Handles RDBMS.
the cursor, freeing the memory used by that cursor. If you Comple
comparatively Class describes a
xity
declare a cursor in a local anonymous, procedure, or simpler data group of objects that
Groupin
Entity type have common
function block, that cursor will automatically close when g
refers to the relationships,
Data
the block terminates. Package-based cursors must be collection of behaviours, and also
Handlin
entities that have similar
closed explicitly, or they stay open for the duration of your g
share a properties.
Exampl
session. Closing a cursor that is not open raises an common Stores data as well
es
definition. as methods to use it.
INVALID CURSOR exception. RDBMS stores db4o, Versant,
docstore.mik.ua/orelly/oracle/langpkt/ch01_09.htm only data. Objectivity/DB
MySQL,
Oracle, SQL
Server
A DML trigger to update the total employee count in
TOTAL_EMPLOYEES table AFTER a record is DELETEd
from EMPLOYEES table can be created as-

​ CREATE TRIGGER update_emp_count


Object-oriented databases are a type of database team members to analyse the data and complete the tasks
management system. Different database management with good quality. By using a centralised database
systems provide additional functionalities. Object-oriented system, individuals and teams can easily share their ideas
databases add the database functionality to object with each other. It becomes easy for the organisation to
programming languages, creating more manageable code coordinate their work with the team members and achieve
bases. their business goals. A Centralised database system also
● Complex data and a wider variety of data types provides a high level of security. Most of the organisations
compared to MySQL data types. prefer to use a centralised database to reduce the conflicts
● Easy to save and retrieve data quickly. within the organisation. Sharing the information with each
● Seamless integration with object-oriented other leads to a happier working environment.
programming languages. Disadvantages of Centralised database: Organisations
may face issues while using a centralised database due to
heavy workload requirements. While using a centralised
VolumeThe prominent feature of any dataset is its size. database system, organisations may have to spend more
Volume refers to the size of data generated and stored in money to manage and store the data.
a Big Data system. We’re talking about the size of data in Advantages: Distributed database system reflects the
organisational structure in an appropriate manner. It
the petabytes and exabytes range. These massive
becomes easy to access the organisational data in an
amounts of data necessitate the use of advanced
effective manner. By using one particular site, users can
processing technology—far more powerful than a typical
access the data stored at different sites easily and
laptop or desktop CPU. As an example of a massive
effectively. Distributed database systems also improve the
volume dataset, think about Instagram or Twitter. People
availability, reliability and performance of the organisation.
spend a lot of time posting pictures, commenting, liking
Failure of one site allows the users to access the
posts, playing games, etc. With these ever-exploding data, information from other sites easily. Distributed database
there is a huge potential for analysis, finding patterns, and systems help the organisations to handle their growth
so much more. Variety Variety entails the types of data expansion. Increase in the database size can easily be
that vary in format and how it is organised and ready for managed by using a distributed database system.
processing. Big names such as Facebook, Twitter, Disadvantage: Distributed database system increases the
Pinterest, Google Ads, CRM systems produce data that complexity and cost of the organisation. It becomes
can be collected, stored, and subsequently analysed. difficult for the organisation to maintain and manage the
Velocity The rate at which data accumulates also local database management system due to which
influences whether the data is classified as big data or organisations may face difficulty to establish a network
regular data. Much of this data must be evaluated in between the sites. In a distributed database system, it
real-time; therefore, systems must be able to handle the becomes difficult for the organisations to control the
pace and amount of data created. The processing speed replicated data. While using a distributed database
of data means that there will be more and more data system, organisations may face difficulty in maintaining the
available than the previous data, but it also implies that the database integrity. Organisations have to spend more on
velocity of data processing needs to be just as high. communication and processing costs to enforce the
integrity constraints. While using a distributed database
system, organisations cannot use static SQL.

Distributed database management system is basically a


set of multiple and logical interrelated databases which is
distributed over the network. It includes a single database
which is further divided into sub fragments. Each fragment
is integrated with each other and is controlled by an
individual database. It provides a mechanism that helps
the users in distributing the data transparently. Distributed
database management system is mostly used in
warehouses to access and process the database of the
clients at single time. Centralised database management
system: Centralised database is another type of database
system which is located, maintained and stored in a single
location such as a mainframe computer. Data stored in the
centralised DBMS is distributed across the network
computers. It includes a set of records which can easily be
accessed from any location by using internet connection
such as WAN and LAN. A centralised database system is
commonly used in organisations such as banks, schools,
colleges etc to manage all their data in an appropriate
manner.
Advantages: With the help of a centralised database
management system, organisations can easily
communicate with each other in less time. This approach
basically allows the team members of an organisation to
work on cross-functional projects. It becomes easy for the

You might also like