NAME
Arjumand Naz
REG NO
740-FOC/BSIT/F22(B)
COURSE CODE:
IT-375
COURSE TITLE:
DATABASE ADMINISTRATION
DESCRIPTION:
This image shows SQL code used to set up two database tables:
Departments and Employees.
First, the code creates the Departments table. It removes any old
Departments table, then defines an ID and a DepartmentName
column. After that, it adds five department entries like 'HR' and
'Engineering'. A message confirms this part was successful.
Second, the code creates the Employees table. It defines columns
for ID, FirstName, LastName, and DeptID. Importantly, the DeptID
column is linked to the Departments table, meaning each
employee must belong to an existing department. Finally, it
inserts ten employee records, and a message confirms that these
were added successfully.
DESCRIPTION:
The image displays the execution of a SELECT * FROM Employees;
SQL query and its results, along with the query's execution plan.
On the left side, the SQL query SELECT * FROM Employees; is
shown at the top. Below it, the "Results" tab is active, displaying
the entire content of the Employees table in a tabular format. This
table has four columns: ID, FirstName, LastName, and DeptID, and
it lists ten employee records. For instance, the first record shows
ID: 1, FirstName: John, LastName: Smith, and DeptID: 1.
On the right side, the "Execution plan" for the SELECT * FROM
Employees; query is visible. This plan provides detailed
information about how the database system processed the query.
Key details visible include:
* Physical Operation: Clustered Index Scan (Clustered)
* Logical Operation: Clustered Index Scan
* Estimated Execution Mode: Row
* Actual Number of Rows Read: 10
* Actual Number of Rows for All Executions: 10
* Output List: Showing the columns retrieved: ID, FirstName,
LastName, and DeptID.
At the bottom of the execution plan, a message "Query executed
successfully." confirms the successful completion of the operation.
DESCRIPTION:
The image displays two distinct SQL query executions, each
demonstrating different aspects of data retrieval and query
optimization.
The upper section shows the execution of SELECT FirstName,
LastName FROM Employees;.
* On the left, the "Results" tab displays a list of only the
FirstName and LastName for all ten employees, effectively
projecting only the specified columns from the Employees table.
* On the right, the "Execution plan" for this query is shown. It
indicates a "Clustered Index Scan (Clustered)" operation, similar
to the previous query, but the "Output List" now explicitly states
that only FirstName and LastName columns are being retrieved.
The lower section illustrates the execution of SELECT * FROM
Employees WHERE DeptID = 3;.
* The query is visible at the top, requesting all columns (*) from
the Employees table but filtered specifically for records where
DeptID is equal to 3.
* Below the query, the "Results" tab shows only two employees:
"Emily Davis" and "Laura Moore," both of whom have a DeptID of
3. This demonstrates the filtering capability of the WHERE clause.
* On the right, a simplified "Execution plan" is displayed. It shows
a "Clustered Index Scan" with a "Cost" of 100%, indicating that
the entire clustered index was scanned to find the matching rows.
Below that, it shows "2 of 2 (100%)", confirming that 2 rows were
found out of a potential 2 rows that match the filter, suggesting
that only 2 employees belong to Department.
DESCRIPTION:
Divided into two parts, demonstrating SQL index creation and its
impact on query performance.
PART 1 focuses on creating an index and analyzing the query plan
before and after.
* The top section of Part 1 shows SQL code attempting to drop an
index (IF EXISTS (SELECT NAME FROM SYS.INDEXES WHERE NAME
= 'idx_DeptID' AND OBJECT_ID = OBJECT_ID('Employees')) DROP
INDEX idx_DeptID ON Employees;) and then creating a new non-
clustered index on the DeptID column of the Employees table
(CREATE INDEX idx_DeptID ON Employees (DeptID);).
* Below this, two query execution plans are displayed, likely
showing the plan before and after the index creation, or perhaps
for different types of queries. The details of these plans, such as
"Nested Loops" and "Clustered Index Seek," with associated costs,
illustrate the database's strategy for data retrieval.
* A "Query executed successfully." message confirms the
completion of the operations in this part.
PART 2 re-examines a SELECT query with a WHERE clause after
the index has been created.
* It shows the SQL query SELECT * FROM Employees WHERE
DeptID = 3; executed twice.
* For each execution, the "Results" tab (though not fully visible in
the second instance) would display the employees belonging to
DeptID = 3.
* More importantly, the "Execution plan" for this query is shown
below each execution. Both plans indicate a "Clustered Index
Scan" with a "Cost" of 100%, and "2 of 2 (100%)" is displayed,
suggesting that two rows matched the criteria. This part primarily
reinforces the result of filtering by DeptID and likely serves to
show if the newly created index had any discernible impact on the
execution plan for this specific query, even if the plan still shows a
full scan (which might happen if the optimizer determines a scan
is still more efficient for small datasets or certain query patterns,
despite an index).