1. Homepage
  2. Homework
  3. CS425 Database Organization - Assignment 2: SQL
This question has been solved

CS425 Database Organization - Assignment 2: SQL

Engage in a Conversation
USIITCS425Database OrganizationSQLIllinois Institute of TechnologyRelational Algebra

Homework Assignment 2

Question 2.1.1

Write the SQL statements for all the five relations:Agent, Managers, Purchaser, Products, and Sales. Note: (1) An appropriate data type should be used for each attribute, and (2) All the foreign keys should be created. CourseNana.COM

Question 2.1.2

Write an SQL statement that adds a constraint to the Agent relation to make sure that the salary attribute cannot be NULL, and the value of this attribute has to be between 60,000 and 300,000. Furthermore, the default value for this attribute should be 90,000. CourseNana.COM

Question 2.2.1

Write an SQL query that returns the products (pid and pname) which are sold by the direct manager(s) of Agent ‘02’ and the quantity for any purchaser (not aggregated) is greater than 250. Hint: relation Managers stores the “managing” information in the company (e.g., the Agent with Agent-id1 is the direct manager of the Agent with Agent-id2 ).
 
CourseNana.COM

Question 2.2.2

Write an SQL query that returns the IDs of all the products, with the total ordered quantity in ‘Boston’ greater than the total ordered quantity in ‘Orlando’.
 
CourseNana.COM

Question 2.2.3

Write an SQL query that returns the name and unit price of all the products (pname and unit_price) which are never ordered by ‘Toyota’. CourseNana.COM

Question 2.2.4

Write an SQL query that returns all the Agents and their average sales amount (of all the purchaser) for each of the products (query result: Agent-id, pid and avg_sales).
 
CourseNana.COM

Question 2.2.5

Write an SQL query that returns all the Agents and the total number of Agents directly managed by each Agent (if no one is directly managed, then return 0). Hint: relation Managers stores the “managing” information in the company (e.g., the agent with Agent-id1 is the direct manager of the agent with Agent-id2 ). CourseNana.COM

Question 2.2.6

Write an SQL query that returns the number of products where the average ordered quantity (of all the Agents and Purchasers) is lower than 400.
 
CourseNana.COM

Question 2.2.7

Write an SQL query that returns the products names and the name of the purchasers with the name of thier companies(s) who ordered the lowest quantity (from all the Agents). Query result: pname and pch-name. CourseNana.COM

Question 2.2.8

Write an SQL query which returns all the Agents’ IDs and their managed Agent’ IDs. Hint: the result should include not only directly managed agents but also indirectly managed agents. CourseNana.COM

Question 2.3.1

Delete all the purchasers without placing any order. CourseNana.COM

Question 2.3.2

We assume that a new product TV is added to the warehouse (available for sale). The unit price is $300. Add the information to the Product relation. Assume that pid is automatically maintained by the system
 
CourseNana.COM

Question 2.3.3

Update the unit_price in the Products relation according to this rule: • if it is negative, set it to 0 • if it is larger than 8,000, then set it to 3,200 • if it is NULL, set it to 5,000 • if none of the above applies do not change the unit_price Note that we expect you to write a single statement that implements this. CourseNana.COM

  CourseNana.COM

Get in Touch with Our Experts

WeChat WeChat
Whatsapp WhatsApp
US代写,IIT代写,CS425代写,Database Organization代写,SQL代写,Illinois Institute of Technology代写,Relational Algebra代写,US代编,IIT代编,CS425代编,Database Organization代编,SQL代编,Illinois Institute of Technology代编,Relational Algebra代编,US代考,IIT代考,CS425代考,Database Organization代考,SQL代考,Illinois Institute of Technology代考,Relational Algebra代考,UShelp,IIThelp,CS425help,Database Organizationhelp,SQLhelp,Illinois Institute of Technologyhelp,Relational Algebrahelp,US作业代写,IIT作业代写,CS425作业代写,Database Organization作业代写,SQL作业代写,Illinois Institute of Technology作业代写,Relational Algebra作业代写,US编程代写,IIT编程代写,CS425编程代写,Database Organization编程代写,SQL编程代写,Illinois Institute of Technology编程代写,Relational Algebra编程代写,USprogramming help,IITprogramming help,CS425programming help,Database Organizationprogramming help,SQLprogramming help,Illinois Institute of Technologyprogramming help,Relational Algebraprogramming help,USassignment help,IITassignment help,CS425assignment help,Database Organizationassignment help,SQLassignment help,Illinois Institute of Technologyassignment help,Relational Algebraassignment help,USsolution,IITsolution,CS425solution,Database Organizationsolution,SQLsolution,Illinois Institute of Technologysolution,Relational Algebrasolution,