Question

In: Computer Science

Examine the structures of the DEPARTMENT and ASSET tables: DEPARTMENT ------------------------- DEPT_ID NUMBER(9) NOT NULL DEPT_ABBR...

  1. Examine the structures of the DEPARTMENT and ASSET tables:

    DEPARTMENT
    -------------------------
    DEPT_ID NUMBER(9) NOT NULL
    DEPT_ABBR VARCHAR2(4)
    DEPT_NAME VARCHAR2(25) NOT NULL
    MGR_ID NUMBER
    
    ASSET
    -----------
    ASSET_ID NUMBER(9) NOT NULL
    ASSET_VALUE FLOAT
    ASSET_DESCRIPTION VARCHAR2(25)
    DEPT_ID NUMBER(9)
    
    The DEPT_ID column of the ASSET table has a FOREIGN KEY constraint referencing the DEPARTMENT table. You attempt to update the ASSET table using 
    this statement:
    UPDATE asset
    SET dept_id =(SELECT dept_id
    FROM department
    WHERE dept_name =(SELECT dept_name
    FROM department
    WHERE dept_abbr = 'FINC')),
    asset_value = 10000
    WHERE asset_id = 2;
    
    Which two statements must be true for this UPDATE statement to execute without generating an error? (Choose two.)
    A.

    An asset with an ASSET_ID value of 2 must exist in the ASSET table.

    B.

    Only one row in the DEPARTMENT table can have a DEPT_ABBR value of FINC.

    C.

    One of the subqueries should be removed because subqueries cannot be nested.

    D.

    Both of the subqueries used in the UPDATE statement must return one and only one non-null value.

    E.

    Only one row in the DEPARTMENT table can have the same DEPT_NAME value as the department with DEPT_ABBR of FINC.

Solutions

Expert Solution

Disambiguating the SQL command first.

UPDATE asset
SET dept_id =(SELECT dept_id
FROM department
WHERE dept_name =(SELECT dept_name
FROM department
WHERE dept_abbr = 'FINC')),
asset_value = 10000
WHERE asset_id = 2;

1. Asset table which have asset_id as 2.
2. Values to set for condition (1) is to put department_id as id which has department_abbr as 'FINC', asset_value as 10000.

Understanding statements

1. An asset with an ASSET_ID value of 2 must exist in the ASSET table.
This is condition on the update statement and not necessarily true. The update command would not do anything if the condition is not met.

2. Only one row in the DEPARTMENT table can have a DEPT_ABBR value of FINC.
This is true. In case it results in multiple rows, the upper subquery would result in multiple DEPT_IDs and would result in error.

3. One of the subqueries should be removed because subqueries cannot be nested.
There is no limit on the number of nested subqueries.

4. Both of the subqueries used in the UPDATE statement must return one and only one non-null value
This is not completely true. The second sub query can return empty result since DEPT_NAME can be null, so it will return single DEPT_ID to be updated with.

5. Only one row in the DEPARTMENT table can have the same DEPT_NAME value as the department with DEPT_ABBR of FINC.
This is correct. If there are multiple such entries, it will result in multiple DEPT_ID and the set command would fail.


Related Solutions

Typing The Answer Is Mandatory Examine the structures of the bulbs to form a conclusion as...
Typing The Answer Is Mandatory Examine the structures of the bulbs to form a conclusion as to the reason that fluorescent bulbs last longer than incandescent bulbs.
Based on this code: CREATE TABLE DEPARTMENT ( DepartmentName Char(35) NOT NULL, BudgetCode Char(30) NOT NULL,...
Based on this code: CREATE TABLE DEPARTMENT ( DepartmentName Char(35) NOT NULL, BudgetCode Char(30) NOT NULL, OfficeNumber Char(15) Not Null, DepartmentPhone Char(12) NOT NULL, CONSTRAINT DEPARTMENT_PK primary key(DepartmentName) ); CREATE TABLE EMPLOYEE( EmployeeNumber Int NOT NULL AUTO_INCREMENT, FirstName Char(25) NOT NULL, LastName Char(25) NOT NULL, Department Char(35) NOT NULL DEFAULT 'Human Resources', Position Char(35) NULL, Supervisor Int NULL, OfficePhone Char(12) NULL, EmailAddress VarChar(100) NOT NULL UNIQUE, CONSTRAINT EMPLOYEE_PK PRIMARY KEY(EmployeeNumber), CONSTRAINT EMP_DEPART_FK FOREIGN KEY(Department) REFERENCES DEPARTMENT(DepartmentName) ON UPDATE CASCADE, CONSTRAINT...
A department store wishes to examine the reasons why customers switch to competing department stores. It...
A department store wishes to examine the reasons why customers switch to competing department stores. It extracts the list of all credit card transactions that happened during last month and selected every tenth name. These customers were subsequently contacted for a detailed survey. Comment on the sampling designs and suggest changes/improvements, if needed. An administrator of an independent hospital wants to find out if single parents working in the hospital have a higher rate of absenteeism than parents who are...
Examine the given​ statement, then express the null hypothesis Upper H 0 and the alternative hypothesis...
Examine the given​ statement, then express the null hypothesis Upper H 0 and the alternative hypothesis Upper H 1 in symbolic form. More than 29​% of Internet users pay bills online. Which of the following is the hypothesis test to be​ conducted? A. Upper H 0​: pequals0.29 Upper H 1​: pnot equals0.29 B. Upper H 0​: pnot equals0.29 Upper H 1​: pequals0.29 C. Upper H 0​: pequals0.29 Upper H 1​: pgreater than0.29 D. Upper H 0​: pless than0.29 Upper H...
String inputStr; double number; try {       inputStr = JOptionPane.showInputDialog(null,             "Please input a number.");      ...
String inputStr; double number; try {       inputStr = JOptionPane.showInputDialog(null,             "Please input a number.");       if (inputStr.equals(""))             throw new IllegalArgumentException("Please enter a number");       number = Double.parseDouble(inputStr);       JOptionPane.showMessageDialog(null,             "The square of the number is " + number * number); } catch (NumberFormatException e) {       JOptionPane.showMessageDialog(null,             "Please enter a valid number to square"); } catch (IllegalArgumentException e) {       JOptionPane.showMessageDialog(null,             e.getMessage()); } finally {       System.exit(0); } 1) First,Why must the two catch blocks...
*tables and figures are listed by page number and are included in the table of contents...
*tables and figures are listed by page number and are included in the table of contents TRUE OR FALSE *WHICH OF THE FOLLOWING IS CORRECT IN TERMS OF APA NUMBER STYLE? a) 1950's b) ten-thousand c) 10 and 20's d) both a and c *when quoting, always provide the author's names, year, complete reference in the reference list, and___________ a) month of publication B) chapter number c)specific page citation d) all the above *which of the following sentences is the...
Prove that the range of a matrix A is equal to the number of singular non-null...
Prove that the range of a matrix A is equal to the number of singular non-null values of the matrix and Explain how the condition number of a matrix A relates to its singular values.
Present and future value tables of $1 at 9% are presented below.     PV of $1...
Present and future value tables of $1 at 9% are presented below.     PV of $1 FV of $1 PVA of $1 FVAD of $1 FVA of $1 1 0.91743 1.09000 0.91743 1.0900 1.0000 2 0.84168 1.18810 1.75911 2.2781 2.0900 3 0.77218 1.29503 2.53129 3.5731 3.2781 4 0.70843 1.41158 3.23972 4.9847 4.5731 5 0.64993 1.53862 3.88965 6.5233 5.9847 6 0.59627 1.67710 4.48592 8.2004 7.5233    Mustard's Inc. sold the rights to use one of its patented processes that will result...
a) What is Asset Liability Management? Enumerate the roles and responsibilities of the various governance structures...
a) What is Asset Liability Management? Enumerate the roles and responsibilities of the various governance structures available to a bank with regard to its interest rate risk management. b) What is Interest Rate Risk? Mention and explain the various sources of interest rate risk in a typical banking book. c) A bank has the following balance sheet extract as at 31st March 2018. Using the table above, i) Calculate 1-year; (a) Rate Sensitive assets (RSAs) (b) Rate Sensitive Liabilities (RSLs)...
Test the null hypothesis that the mean difference in the number of cases lost on appeal...
Test the null hypothesis that the mean difference in the number of cases lost on appeal for the two groups of judges is zero against the alternative hypothesis that the untrained judges lose more cases on appeal. Use an alpha level of .01. Judge Untrained Trained 1 3 0 2 1 3 3 2 4 4 7 4 5 5 2 6 4 5 7 6 1 8 2 1 9 7 0 10 5 6 11 3 4 12...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT