CMPTR
3rd Edition
ISBN: 9781337681872
Author: PINARD
Publisher: Cengage
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Please provide a correct, clear answer for this SQL question
8)
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Write the SQL code to calculate the ASSIGN_CHARGE values in the ASSIGNMENT table in the Ch07_ConstructCo database. (See Figure P7.1.) Note that ASSIGN_CHARGE is a derived attribute that is calculated by multiplying ASSIGN_CHG_HR by ASSIGN_HOURS.arrow_forwardWrite the SQL code that will restore the data to its original status: that is, the table should contain the data that existed before you made the changes in Problems 5 and 6.arrow_forwardstudent(sid, sname, sex, age, year, gpa) dept(dname, numphds) prof(pname, dname) course(cno, cname, dname) major(dname, sid) section(dname, cno, sectno, pname) enroll(sid, grade, dname, cno, sectno) Write the following SQL queries for the schema above: Print the course names, course numbers and section numbers of all classes with less than six students enrolled in them. Print the name(s) and sid(s) of the student(s) enrolled in the most classes. Print the names of departments that have one or more majors who are under 18 years old. Print the names and majors of students who are taking one of the College Geometry courses. For those departments that have no majors taking a College Geometry course, print the department name and the number of PhD students in the department. Print the names of students who are taking both a Computer Sciences course and a Mathematics course. For each department that has one or more majors with a GPA under 1.0, print the name of the…arrow_forward
- SQL DML/DDL There are five tables describing employees of a company, departments, buildings, which department(s) an employee works in (and a percentage of the time for each), and in which building an employee works (an employee may have more than one office). The primary key of each table is the attribute(s) in capitals and underlined. The foreign keys are in italics. Other attributes are not necessarily unique.Employee (EID, Ename, Salary, Start_Date, End_Date)Building (BID, Bname, Address)Department (DID, Dname, Annual_Budget)In_Department (EID, DID, Percentage_Time)In_Building (EID, BID)Write the SQL statements for the following.1. Find the names of Departments where NO employees work. 2. For employees who are still working in the company, end date has no value (empty). For those who have left the company and have end date values, show their names and the duration of their employment in years. 3. Find the names of buildings where more than 50 employees work. 4. The tables have…arrow_forward3.Write a SQL statement to create a stored procedure called Calc_Average based on the Semester_Marks table created in Table 2: Semester_Marks table structure.The stored procedure should update the total marks, no of courses and calculate the average mark for each student. (Note: Average mark = total_mark divide by the number of courses for the student.).Control the flow of your code should an error occur (e.g. number of courses enter is zero). Use exception handling to avoid zero being entered for the number of courses. 4.Write a statement to create a procedure which accepts a discount as input. The procedure should have two conditions. Firstly, if the discount is between 1 to 15 percent, the base amount should be increased with 1000 and the increased value is printed, secondly if the discount is between 16 to 30 percent the base amount should be decreased with 500 and the decreased value is printed. Write a statement to invoke the procedure.arrow_forwardUSE this part to write SQL statements Branch(branch_id:integer, branch_name:varchar(50), branch_location:varchar(40), money_on_hand:numeric(15,2) create table Branch (branch_id integer, branch_name varchar(50), branch_location varchar(40), money_on_hand numeric(15,2), primary key (branch_id)); Loan(loan_number:integer, branch_id:integer, amount:numeric(8,2)) foreign key branch_id references Branch(branch_id) create table Loan (loan_number integer, branch_id integer, amount numeric(8,2), primary key (loan_number), foreign key (branch_id) references Branch (branch_id)); Customer(customer_id:integer, customer_last_name:varchar(35),customer_first_name:varchar(25), customer_street:varchar(30), customer_zip:integer) create table…arrow_forward
- FirstName EID Name LastName Employee Birthdate TEL Age) n work date ID Name m Project Rate In the physical design phase, which SQL statement is the most correct one to create the Employee table in the above E-R diagram for the MySQL database? create table Employee (EID varchar(10) primary key, FirstName varchar(50), LastName varchar(50), Age int, Birthday date, TEL varchar(20)); create table Employee (EID varchar(10) primary key, FirstName varchar(50), LastName varchar(50), Birthday date); create table Employee (EID varchar(10) primary key, Name varchar(50), TEL varchar(20)); create table Employee (EID varchar(10) primary key, Name varchar(50), Age int, Birthday date);arrow_forwardhttps://sqliteonline.com/ : Program link The first requirement: Using the SQL language, transform the following entity model into tables in the database. Entity Manger contains: M-name The name of the manager. M-ID and manager number.The department entity contains: D-name The name of the department. D-ID and department number.Create constraint master key name of the manager when creating the Manger table.Creating the foreign key constraint The name of the manager when creating the Department table. The second requirement: After creating the tables and specifying the primary and foreign key, do the following: * Add a column D_loc to the Department table, specifying the type of column.* Remove the column named M_name from the Manger table* Change the name of the department table to Dep Please:: ******* ATTACH A PICTURE OF THE CODES USED AND PICTURE OF THE PROGRAM SCREEN *******arrow_forwardTrying to write statements for these shown here and having issues with them workingarrow_forward
- Question 5 You are working with a database table that contains customer data. The table includes columns about customer location such as city, state, country, and postal_code. You want to check for postal codes that are greater than 7 characters long. You write the SQL query below. Add a LENGTH function that will return any postal codes that are greater than 7 characters long. 1 2 3 4 5 SELECT * FROM customer WHERE RunReset What is the last name of the customer that appears in row 10 of your query result? 1 pointarrow_forwardIn SQL This sample database consists of the following tables(see image for tables and there is one more at the bottom in this text):• Customers: stores customer’s data• Products: stores a list of scale model cars• ProductLines: stores a list of product line categories• Orders: stores sales orders placed by customers• OrderDetails: stores sales order line items for each sales order• Payments: stores payments made by customers based on their accounts• Employees: stores all employee information as well as the organization structuresuch as who reports to whom• Offices: stores sales office data Write SQL code for the following:We want to add a new sale order for the customer (customerNumber = 145) in thedatabase. The steps of adding a sale order are described as follows:(1) Get latest sale order number from “orders” table, and use the next sale ordernumber as the new sale order number(2) Insert a new sale order into “orders” table for the customer (customerNumber =145). For this order, the…arrow_forwardIn SQL This sample database consists of the following tables(see image for tables and there is one more at the bottom in this text):• Customers: stores customer’s data• Products: stores a list of scale model cars• ProductLines: stores a list of product line categories• Orders: stores sales orders placed by customers• OrderDetails: stores sales order line items for each sales order• Payments: stores payments made by customers based on their accounts• Employees: stores all employee information as well as the organization structuresuch as who reports to whom• Offices: stores sales office data Write SQL code for the following:We want to add a new sale order for the customer (customerNumber = 145) in thedatabase. The steps of adding a sale order are described as follows:(1) Get latest sale order number from “orders” table, and use the next sale ordernumber as the new sale order number(2) Insert a new sale order into “orders” table for the customer (customerNumber =145). For this order, the…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781285196145Author:Steven, Steven Morris, Carlos Coronel, Carlos, Coronel, Carlos; Morris, Carlos Coronel and Steven Morris, Carlos Coronel; Steven Morris, Steven Morris; Carlos CoronelPublisher:Cengage LearningNp Ms Office 365/Excel 2016 I NtermedComputer ScienceISBN:9781337508841Author:CareyPublisher:Cengage
- Database Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781305627482Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningA Guide to SQLComputer ScienceISBN:9781111527273Author:Philip J. PrattPublisher:Course Technology Ptr
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781285196145
Author:Steven, Steven Morris, Carlos Coronel, Carlos, Coronel, Carlos; Morris, Carlos Coronel and Steven Morris, Carlos Coronel; Steven Morris, Steven Morris; Carlos Coronel
Publisher:Cengage Learning
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:9781337508841
Author:Carey
Publisher:Cengage
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781305627482
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
A Guide to SQL
Computer Science
ISBN:9781111527273
Author:Philip J. Pratt
Publisher:Course Technology Ptr