Question

In: Computer Science

LP3.1 Assignment: Using Advanced SQL This assignment will assess the competency 3. Construct advanced SQL queries....

LP3.1 Assignment: Using Advanced SQL

This assignment will assess the competency 3. Construct advanced SQL queries.

Directions: Using the sample dataset, create three queries including a search, outer join and subquery. Create a table on how to use the query optimizer with these queries. Include screenshots and an explanation on why and when to use the optimizer.

.

Solutions

Expert Solution

Sample Data sets attached below:

Outer Join or Full join

1.It returns all the matching records from both the tables, whether the other table matches or not.

2. It will return very large data set, comparing to other joins.

Syntax for Outer Join

SELECT Column-names FROM table_1 FULL OUTER JOIN table_2 ON column_1 = column+2

Where conditions

Example:

Here we are using the outer join to display all the fields in both the tables above.

Select first_name, last_name, order_date, order_date

From customer c full join order o

on c.customer_id = o.customer_id.

Search query in SQL:

There are various type of search queries available in SQL, either by char fields, integer fieds, and so on.

1. For example

   To select the person with first_name george

select * from customer where first_name = 'george';

2. For example

    To select person with customer_id 4

Select * from customer where customer_id = 4;

Subqueries:

An sql sub query is a query within another query embedded within where clause.

It can be used with select, update, insert, delete.

Condition for sub queries;

1. Enclosed within paranthesis

2. Order by can't be used.

3. Can't be immediiately enclosed in set function.

For example: Select * from customers where ID in (select ID from cuustomers where salary > 4500).

Query optimizing or Tuning

It is process of ensuring that, sql statements that an application will issue will run in fastest possible time. Just like there are different ways to repair my TV, there are different ways to wirte queries, we have to optimize for better results.

Example:

CREATE TABLE sql_tuning_a
(
    ID NUMBER(38)
);

CREATE TABLE sql_tuning_b
(
    ID NUMBER(38)
);

After Query Optimizing:

SELECT COUNT(*)
FROM sql_tuning_a a, sql_tuning_b b
WHERE a.id = b.id;


Related Solutions

This assignment will assess the competency 6. Construct an application that successfully utilizes MySQL features. Directions:...
This assignment will assess the competency 6. Construct an application that successfully utilizes MySQL features. Directions: Create short description of a PHP/MySQL project you could develop. Include a description of how it would be used, why it would be used and how MySQL and a PHP page would interact.
In this assignment, you are required to write the SQL statements to answer the following queries...
In this assignment, you are required to write the SQL statements to answer the following queries using PostgreSQL system. The SQL statements comprising the DDL for Henry Books Database are given to you in two files. For that database, answer the following queries. Create the files Q1 to Q10 in PostgreSQL. Do follow the restrictions stated for individual queries. 1. List the title of each book published by Penguin USA. You are allowed to use only 1 table in any...
Directions This assignment will assess the competency 1. Evaluate the role of HR, 3. Examine organization...
Directions This assignment will assess the competency 1. Evaluate the role of HR, 3. Examine organization capabilities for human resource management, & 4. Create a human resource capabilities model. As part of understanding the respective theories discussed and applying them to organizations to create a competitive advantage, you will have the opportunity to assess a particular aspect or aspects of the HR strategy at an organization and how the particular strategy supports the organization’s strategic business objectives. An introduction. An...
For Assignment 2, submit a word or pdf file with the SQL queries along with screenshots...
For Assignment 2, submit a word or pdf file with the SQL queries along with screenshots of the outputs. (It is ok if the whole problem cannot be answered, if possible, I just would like an idea of how to begin, thanks in advance!) 9. Write a query to count the number of invoices. 10. Write a query to count the number of customers with a balance of more than $500. 11. Generate a listing of all purchases made by...
LP8 Assignment: CMS Director This assignment will assess the competency 8. Evaluate trends that will affect...
LP8 Assignment: CMS Director This assignment will assess the competency 8. Evaluate trends that will affect the long-term care system in the future as well as challenges facing managers in the long-term care system of the future. Prepare a 3-4 page, double-spaced paper (cite 3-4 reliable sources) that addresses the following scenario: You are the newly appointed director of the Center for Medicare and Medicaid Services (CMS). With health care costs continuing to soar, the Medicare Modernization Act (MMA) rollout...
COMPENSATION AND BENEFITS LP2 Assignment: Internal Equity and Job Analysis This assignment will assess the competency...
COMPENSATION AND BENEFITS LP2 Assignment: Internal Equity and Job Analysis This assignment will assess the competency 2. Determine the critical aspects pertaining to the internal alignment of compensation polices and techniques. Directions: Write a paper that addresses the following questions: • Define “internal equity” and explain the reason for its existence and its impact on the organization. • What does job analysis have to do with internal alignment? • What is the critical advantage of quantitative approaches over conventional approaches...
LP7 Assignment: IT System for St. Timothy’s This assignment will assess the competency 7. Analyze potential...
LP7 Assignment: IT System for St. Timothy’s This assignment will assess the competency 7. Analyze potential applications of an information technology system and marketing strategies and the impact of changes in regulations. Prepare a 3-4 page, double-spaced paper (cite 3-4 reliable sources) that addresses the following scenario: You are the Director of Continuing Care Services for St. Timothy’s Health Care System, a multilevel system consisting of an array of acute and long-term services. You have been given the task of...
his assignment will assess competency 3. Analyze the fundamental characteristics of organizing. Throughout your career, especially...
his assignment will assess competency 3. Analyze the fundamental characteristics of organizing. Throughout your career, especially as a manager, you will have to understand and work in a variety of structural configurations. Changing times may force you to participate or lead a reorganization for your company. It is important to understand the structure and the effect it can have on achieving company goals. For your paper: Research and describe how the scholarly literature describes the functional and divisional approaches to...
Basic SQL Use the following schema to answer the queries below using SQL DEVICE [dno, dtype,...
Basic SQL Use the following schema to answer the queries below using SQL DEVICE [dno, dtype, price] PROVIDER [pno, pname, web] SERVICE [dno, pno, servicedate] SERVICE.dno references DEVICE.dno SERVICE.pno references PROVIDER.pno bold is underline. a) Find the dno for the most expensive device b) Find all providers that have the work fast in the name c) Find the number of different device types (dtype) d) Give all details of devices with price more than $400
Using your downloaded DBMS (MS SQL Server or MySQL), write SQL queries that inserts at least...
Using your downloaded DBMS (MS SQL Server or MySQL), write SQL queries that inserts at least three rows in each table. For the On-Demand Streaming System, First, insert information for multiple users, at least three video items and insert the three different types of subscriptions (Basic, Advanced, Unlimited) into the database. Then insert at least three user subscriptions. Execute the queries and make sure they run correctly
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT