Final
Final
In a relational database, data is stored in one or more tables (or "relations") of columns and
rows, making it simple to see and comprehend how various data structures relate to one
another. Data is organized in relational databases according to predetermined relationships.
RDBMS is a program used to create, update, and manage relational databases. For example,
MySQL
List and explain the different types of JOIN clauses supported in ANSI-
standard SQL. Support with example.
There are six types of join in SQL:
1- The INNER JOIN keyword selects records that have matching values in both tables.
SELECT column_name(s)
FROM table1
INNER JOIN table2
ON table1.column_name = table2.column_name;
2- The LEFT JOIN keyword returns all records from the left table (table1), and the
matching records from the right table (table2).
SELECT column_name(s)
FROM table1
LEFT JOIN table2
ON table1.column_name = table2.column_name;
3- The RIGHT JOIN keyword returns all records from the right table (table2), and the
matching records from the left table (table1).
SELECT column_name(s)
FROM table1
RIGHT JOIN table2
ON table1.column_name = table2.column_name;
4- The FULL OUTER JOIN keyword returns all records when there is a match in left
(table1) or right (table2) table records.
SELECT column_name(s)
FROM table1
FULL OUTER JOIN table2
ON table1.column_name = table2.column_name
WHERE condition;
5- CROSS JOIN: Returns all records where each row from the first table is combined
with each row from the second table.
SELECT ColumnName_1,
ColumnName_2,
ColumnName_N
FROM [Table_1]
CROSS JOIN [Table_2]
6- A self-join is a regular join, but the table is joined with itself.
SELECT column_name(s)
FROM table1 T1, table1 T2
WHERE condition;
Write a query to get the list of users who took a training lesson more
than once on the same day, grouped by user and training lesson, each
ordered from the most recent lesson date to the oldest date.
SELECT
s.user_id, training_date, username, training_id,
count( user_training_id ) AS num
FROM
users s JOIN training_details d ON d.user_id = s.user_id
GROUP BY
s.user_id, username, training_id, training_date
HAVING
count( user_training_id ) > 1
ORDER BY training_date DESC;
Client Layer:
This layer is the topmost layer in the above diagram. The Client gives request instructions to
the Serve with the help of Client Layer. The Client make request through Command Prompt
or through GUI screen by using valid MYSQL commands and expressions, Some important
services of client layer are :
Connection Handling.
Authentication.
Security.
Server Layer:
The second layer of MYSQL architecture is responsible for all logical functionalities of
relational database management system of MYSQL. This Layer of MYSQL System is also
known as “Brain of MYSQL Architecture”. When the Client give request instructions to the
Server and the server gives the output as soon as the instruction is matched.
Storage Layer:
This Storage Engine Layer of MYSQL Architecture make it’s unique and most preferable for
developers. Due to this Layer MYSQL layer is counted as the mostly used RDBMS and is
widely used. In MYSQL server, for different situations and requirement’s different types of
storage engines are used which are InnoDB ,MYiSAM , NDB ,Memory etc. These storage
engines are used as pluggable storage engineer where tables created by user are plugged
with them.
shared Pool check – Every query possess a hash code during its execution. So, this check
determines existence of written hash code in shared pool if code exists in shared pool then
database will not take additional steps for optimization and execution.
Phase 2:
Optimizer: During optimization stage, database must perform a hard parse atleast for one
unique DML statement and perform optimization during this parse. This database never
optimizes DDL unless it includes a DML component such as subquery that require
optimization.
Row Source Generation –
The Row Source Generation is a software that receives a optimal execution plan from the
optimizer and produces an iterative execution plan that is usable by the rest of the database.
Phase 3:
Execution Engine: Finally runs the query and display the required result