A Guide to SQL
9th Edition
ISBN: 9781111527273
Author: Philip J. Pratt
Publisher: Course Technology Ptr
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 7, Problem 11SCG
Program Plan Intro
Foreign key:
- A primary key attribute in one table is the foreign key for another table. In logical way, a foreign key is used to establish a relationship between two tables.
- A foreign key is used for identifying a row of another table uniquely.
- Foreign keys are represented in italic form.
ALTER TABLE Statement:
- “ALTER TABLE” statement comes under Data Definition Language (DDL).
- It is used to modify column, add constraints, add column(s), drop column, rename column name and table name, drop constraints, and so on.
Syntax:
The Syntax to drop constraint is as follows:
ALTER TABLE table_Name ADD CONSTRAINT constraint_Name;
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
Using nwind database, create a query to show company name, product name, and quantity for items ordered where the quantity is greater that the average quantity for that customer. If the average of a customer is 15, than items ordered by that customer with a quantity more than 15 should be shown in the results. Note quantity field is in order_details table. You must use a corelated subquery for this problem. sql workbench
Write an appropriate SQL query to determine if there are any students that are not registered for any modules.Sample results:STUDENT_ID STUDENTS654321 Joe, ThaboRequirementsCorrect SELECT statement used. Correct JOIN used. Correct WHERE clause. Question 7 Write an appropriate SQL query to delete the following record from the STUDENTS table: STUDENT_ID: S654321STUDENT_SURNAME: JoeSTUDENT_NAME: ThaboRequirementsCorrect DELETE statement used. Correct WHERE clause.
please assist with the following questions.
need to write a syntax in SQL server.
Create an UPDATE trigger called tr_check_qty on the OrderDetails table to prevent the updating of the quantity in the OrderDetails table if the quantity amount is greater than the units in stock in the Products table.
Chapter 7 Solutions
A Guide to SQL
Ch. 7 - What is a view?Ch. 7 - Which command creates a view?Ch. 7 - Prob. 3RQCh. 7 - What happens when a user retrieves data from a...Ch. 7 - What are three advantages of using views?Ch. 7 - Which command deletes a view?Ch. 7 - Prob. 8RQCh. 7 - Which command terminates previously granted...Ch. 7 - Prob. 10RQCh. 7 - How do you create an index? How do you create a...
Ch. 7 - Prob. 12RQCh. 7 - Does the DBMS or the user make the choice of which...Ch. 7 - Describe the information the DBMS maintains in the...Ch. 7 - The CUSTOMER table contains a foreign key,...Ch. 7 - Prob. 16RQCh. 7 - Prob. 17RQCh. 7 - Prob. 18RQCh. 7 - Prob. 19RQCh. 7 - When would you usually specify primary key...Ch. 7 - Prob. 21RQCh. 7 - Prob. 22RQCh. 7 - Prob. 23RQCh. 7 - Use SQL to make the following changes to the TAL...Ch. 7 - Create a view named ITEM_ORDER. It consists of the...Ch. 7 - Create a view named ORDER_TOTAL. It consists of...Ch. 7 - Write, but do not execute, the commands to grant...Ch. 7 - Prob. 5TDCh. 7 - Perform the following tasks: a. Create an index...Ch. 7 - Delete the index named ITEM_INDEX3.Ch. 7 - Write the commands to obtain the following...Ch. 7 - Prob. 9TDCh. 7 - Prob. 10TDCh. 7 - Toys Galore currently has a credit limit of 7,500....Ch. 7 - Use SQL to make the following changes to the...Ch. 7 - Create a view named RESERVATION_CUSTOMER. It...Ch. 7 - Create a view named TRIP_INVENTORY. It consists of...Ch. 7 - Write, but do not execute, the commands to grant...Ch. 7 - Prob. 5CATCh. 7 - Create the following indexes: a. Create an index...Ch. 7 - Prob. 7CATCh. 7 - Write the commands to obtain the following...Ch. 7 - Prob. 9CATCh. 7 - Ensure that the only legal values for the TYPE...Ch. 7 - Prob. 11CATCh. 7 - Use SQL to make the following changes to the...Ch. 7 - Create a view named CONDO_OWNERS. It consists of...Ch. 7 - Create a view named CONDO_FEES. It consists of two...Ch. 7 - Write, but do not execute, the commands to grant...Ch. 7 - Prob. 5SCGCh. 7 - Prob. 6SCGCh. 7 - Delete the OWNER_INDEX 3 index from the OWNER...Ch. 7 - Write the commands to obtain the following...Ch. 7 - Prob. 9SCGCh. 7 - Ensure that the only legal values for the BDRMS...Ch. 7 - Prob. 11SCG
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
- Use %ROWTYPE for your cursor. You will use 3 tables in this activity - departments, locations, and countries. Write a PL/SQL block to read and display the department name, city and country name from departments 10, 30, and 90. Display also the number of records returned by your PL/SQL block.arrow_forwardIn the SQL Oracle Application, Within the Employees table, each manager_id is the manager of one or more employees who each have a job_id and earn a salary. For each manager, what is the total salary earned by all of the employees within each job_id? Write a query to display the Manag-er_id, job_id, and total salary. Include in the result the subtotal salary for each manager and a grand total of all salariesarrow_forwardWrite a SQL query to find the customer# of those customers that purchased at least once in July 2020 but NOT in August 2020. In addition to the customer#, show the ISBN and title of the book(s) they purchased in July 2020. You may use only one query. No creating any temporary tables or subqueries. You may use only joins. SUBMIT a second solution in addition to your Level 1.arrow_forward
- please use sql to answer the following question Create a procedure, ADD_EMPLOYEE., to insert a new employee into the EMPLOYEES table. The procedure should call a VALID_DEPTID function to check whether the department ID specified for the new employee exists in the DEPARTMENTS table. d, Add another employee named Joe Harris in department 80. leaving remaining parameters with their default values. What is the result?arrow_forwardOpen the CounselorSkillsQuery in SQL View. Add a caption to the Specialty field in the SELECT clause. (Hint: Use the AS clause.) Use SpecialSkills as the caption for the Specialty field Given SQL: SELECT CounselorID, FirstName, LastName, SpecialtyFROM Counselor;arrow_forwardYou are working with a database table that contains invoice data. The table includes columns for invoice_id and invoice_date. You want to remove duplicate entries for invoice_date. You write the SQL query below. Add a DISTINCT clause that will remove duplicate entries from the invoice_date column.arrow_forward
- please use sql to answer the following question Create a procedure, ADD_EMPLOYEE., to insert a new employee into the EMPLOYEES table. The procedure should call a VALID_DEPTID function to check whether the department ID specified for the new employee exists in the DEPARTMENTS table. c. Call ADD_EMPLOYEE for the name Jane Harris in department 15. leaving other parameters with their default values. What is the result?arrow_forwardUsing the software.subscription table, pull all columns for subscriptions that have been cancelled. Use the results from the attachment to determine which column you need to filter on in your where clause. This is to write a query in a database.arrow_forwardQ3: How many unique titles do we have in the employee table? Hint: You need to create TWO queries, 1. The first query returned all the unique titles, i.e., Q03_Unique Titles (use the Distinct keyword and use the SQL View to type in the SQL statement directly (Design View will not work). Please refer to SQL_MIS310 slide#105-107 for guidance. You cannot use Distinct and Count together in Access and this is why you have to do it in two related two queries.). The second query is a query against the first query (i.e., Q03_UniqueTitles) and count the number of unique titles (Use the aggregate function Count) and the query should return a number. 2. The second query is named Q03_UniqueTitlles_Count and it has been created for you already. You should use Q03_UniqueTitles (not a table) to create this query. This query should return a result that is a simple number.arrow_forward
- Please write a query for dvdrental database. Please list all the customers. For each customer display following information: • Customer Id • First Name • Last Name • Rental price for most expensive movie rented in May 2005 by this customer • Rental price for most expensive movie rented in June 2005 by this customer • Rental price for most expensive movie rented in July 2005 by this customer Final query should have 6 columns, one row for each customer For rental price use “rental_rate” column from film table. Sort results by customer last name. postgresarrow_forwardCreate a new table, EMP_PROMOTION to store the employees information. You must use a subquery to create the new table. Make the salary column invisible. Display the structure of the table in SQL Developer. Also use a SELECT statement to display all records from the new table EMP_PROMOTION.arrow_forwarduse oracle sql command line which has HR schema to display this query.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- A Guide to SQLComputer ScienceISBN:9781111527273Author:Philip J. PrattPublisher:Course Technology PtrDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781305627482Author:Carlos Coronel, Steven MorrisPublisher:Cengage Learning
- 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 Learning
A Guide to SQL
Computer Science
ISBN:9781111527273
Author:Philip J. Pratt
Publisher:Course Technology Ptr
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781305627482
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
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