Question

In: Computer Science

1. Can you please describe the different kinds of joins used in SQL? 2. What SQL...

1. Can you please describe the different kinds of joins used in SQL?
2. What SQL syntax would you use to ensure you are not returning duplicates in your data sets?
3. What SQL syntax would you use to change data in a table if you had write access to the table? Having write access means the data manipulation would occur in the table being pulled from.
4. What SQL syntax would you use to change data in a table if you only had read access to the table? Having read access means the data manipulation would occur in the dataset rather than in the table being pulled from.
5. What methodologies could you use to improve the performance of a SQL query?
6. What SQL syntax could you use to filter date ranges in your dataset?

Solutions

Expert Solution

QUES 1. Consider the tables as follows :-

The result of JOIN is shown in the third table :-

Query :-

     

SELECT ID, NAME, AGE, AMOUNT

FROM CUSTOMERS, ORDERS

WHERE CUSTOMERS.ID = ORDERS.CUSTOMER_ID;

 

SELECT ID, NAME, AGE, AMOUNT

FROM CUSTOMERS

<JOIN_TYPE> ORDERS ON CUSTOMERS.ID = ORDERS.CUSTOMER_ID;

The <JOIN_TYPE> can be one of the top 4 of the following :-

1. INNER JOIN :- returns the set of rows that are common to both tables. In short, it performs an intersection from both tables. The inner keyword is optional as illustrated above.

2. LEFT JOIN :- returns all records from left table and it doesn't matter if there are no matches in the right table.

3. RIGHT JOIN :- returns all records from the right table and it doesn't matter if there are no matches for the corresponding entries in left table.

4. FULL JOIN :-  returns all records where there is a match in one of the tables. It is equivalent to union operation on both tables.

5. CARTESIAN JOIN :- returns the cartesian product of the sets of rows from the joined tables

6. SELF JOIN :- used to join a table to itself as if it were two separate tables, temporarily renaming one of them using an alias

** 5. & 6. are rarely used, so they can also be omitted.

If you liked this answer, please give a thumbs up rating. Feel free to comment for any explanations/ clarifications.


Related Solutions

Can you please describe the different kinds of joins used in SQL?
Can you please describe the different kinds of joins used in SQL?
1. What is one of the most powerful features of SQL? Operators Functions Table Joins 2....
1. What is one of the most powerful features of SQL? Operators Functions Table Joins 2. A JOIN is a mechanism used to associate tables within a SELECT statement? True False 3. A JOIN can modify existing database tables True False None of the above 4. The WHERE clause acts as a filter to only include rows that match the filter condition. True False 5. The more tables you JOIN the less resources the system uses. True False 6. The...
Having learned different kinds of costs and the systems used to accumulate them, what kinds of...
Having learned different kinds of costs and the systems used to accumulate them, what kinds of costs would a social media company like Twitter or Tik-Tok, would incur? Are there labor, material, and overhead costs? Are there fixed and variable costs and direct and indirect costs? What are the types of services produced by social media companies? And how do the costs incurred relate to the services they generate? (300 words) C-5: As a cost accountant of a company that...
1. Write a SQL statement which joins the rider_student table with the rider_major table and lists...
1. Write a SQL statement which joins the rider_student table with the rider_major table and lists the rider student name and the name of the major (major_name) and the description of the major for which they are currently assigned. (You may use the SQL 'join' subclause, or simply express the join as part of the 'where' clause by indicating that you only want records where the primary key of the child table, rider_major, equals the corresponding foreign key of the...
1.list different kinds of worker required to design, build and move in to a house 2.can...
1.list different kinds of worker required to design, build and move in to a house 2.can all these jobs be done by one person? why?
1.) What kinds of drugs would you develop to combat viral infections? 2.) Frederick Griffith used...
1.) What kinds of drugs would you develop to combat viral infections? 2.) Frederick Griffith used mice and a pneumonia causing bacterium to demonstrate that dna is the basis of transformation. why is it called transformation not conjugation or transduction?
2. Describe the basic principle of DCFs and how they can be used to compare different...
2. Describe the basic principle of DCFs and how they can be used to compare different streams of cash flows.
Describe two kinds of scale economies. What different implications do the two kinds of scale economies...
Describe two kinds of scale economies. What different implications do the two kinds of scale economies have for regional economic development?
Describe two kinds of scale economies. What different implications do the two kinds of scale economies...
Describe two kinds of scale economies. What different implications do the two kinds of scale economies have for regional economic development?
Please Answer the questions listed in the comment section, 1 and 2! -- ==================================================================== -- SQL...
Please Answer the questions listed in the comment section, 1 and 2! -- ==================================================================== -- SQL Script for Bookstore Database Records -- This script demonstrates the use of transactions for Unit 13 Exercise -- -- Created by: Jennifer Rosato -- Created on: 12/2013 -- Modified by: David Vosen -- Modified on: 11/2016 -- Modified on: 11/2018 Add DBCC LOG(CIS_3107_##, 1) to view -- transactions. -- ==================================================================== --SELECT * FROM customer; --SELECT * FROM invoice; --SELECT * FROM line; --SELECT *...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT