Preview

Assignment Homework

Powerful Essays
Open Document
Open Document
1073 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Assignment Homework
Name:

Homework (50 points)
Using the student schema from week 2, provide answers to the following questions.
Question
SQL statement or Answer
1. Generate statistics for the student, enrollment, grade, and zipcode tables (15 pts)

SQL> EXEC DBMS_STATS.GATHER_TABLE_STATS('D02246617', 'STUDENT');

SQL> EXEC DBMS_STATS.GATHER_TABLE_STATS('D02246617', 'ENROLLMENT');

SQL> EXEC DBMS_STATS.GATHER_TABLE_STATS('D02246617', 'GRADE');

SQL> EXEC DBMS_STATS.GATHER_TABLE_STATS('D02246617', 'ZIPCODE');

SQL> BEGIN 2 DBMS_STATS.GATHER_TABLE_STATS('D02246617', 'STUDENT'); 3 END; 4 /

SQL> BEGIN 2 DBMS_STATS.GATHER_TABLE_STATS('D02246617', 'ENROLLMENT'); 3 END; 4 /

PL/SQL procedure successfully completed.
…show more content…
SQL> BEGIN 2 DBMS_STATS.GATHER_TABLE_STATS('D02246617', 'ZIPCODE'); 3 END; 4 /

PL/SQL procedure successfully completed.

SQL> DESCRIBE USER_TABLES;

SQL> SELECT TABLE_NAME, NUM_ROWS FROM USER_TABLES;
2. Write queries that performs a join, a subquery, a correlated subquery using the student, enrollment, grade, and zipcode tables. Execute each query to show that it produces the same results. (15 pts)
SQL> SELECT S.LAST_NAME, Z.ZIP 2 FROM STUDENT S JOIN ZIPCODE Z 3 ON Z.ZIP = S.ZIP 4 WHERE STATE = 'MI';

SQL> SELECT LAST_NAME, ZIP 2 FROM STUDENT S 3 WHERE ZIP IN (SELECT ZIP 4 FROM ZIPCODE Z WHERE STATE = 'MI');

SQL> SELECT LAST_NAME, ZIP 2 FROM STUDENT
…show more content…
Execution Plan
----------------------------------------------------------
Plan hash value: 775439700
-----------------------------------------------------------------------------
| Id| Operation | Name | Rows| Bytes |Cost (%CPU)| Time |
-----------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 35 | 805 | 6 (17)| 00:00:01 |
| 1 | SORT ORDER BY | | 35 | 805 | 6 (17)| 00:00:01 |
| 2 | NESTED LOOPS | | 35 | 805 | 5 (0)| 00:00:01 |
| 3 | TABLE ACCESS FULL | STUDENT | 268 | 3752 | 3 (0)| 00:00:01 |
|*4 | TABLE ACCESS BY INDEX ROWID| ZIPCODE | 1 | 9 | 1 (0)| 00:00:01 |
|*5 | INDEX UNIQUE SCAN | ZIP_PK | 1 | | 0 (0)| 00:00:01 |
-----------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
4 - filter("Z"."STATE"='CT') 5 - access("S"."ZIP"="Z"."ZIP")

Statistics
----------------------------------------------------------
0 recursive calls 0 db block

You May Also Find These Documents Helpful

  • Satisfactory Essays

    Investment income and related expenses amount to $7,000 and $500, respectively. What is Mike and Sally's interest deduction for the 2012 tax year?…

    • 309 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    CAUA 8

    • 1452 Words
    • 5 Pages

    Q 1: Perform Verify and Count Commands for all three tables and identify any exceptions.…

    • 1452 Words
    • 5 Pages
    Good Essays
  • Satisfactory Essays

    Extract the First and Last Name, Address, City, State, Zip Code and Phone Number of each senior on the database. Sort by Last Name, then First Name (1 sort).…

    • 325 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Unit 53 Final Paper

    • 383 Words
    • 2 Pages

    Write a query that displays the last name (with the first letter in uppercase and all other letters in lowercase) and the length of the last name for all employees whose name starts with the letters “J”, “A”, or “M.” Give each column an appropriate label. Sort the results by the employee’s last names.…

    • 383 Words
    • 2 Pages
    Good Essays
  • Satisfactory Essays

    Hrm Labor

    • 363 Words
    • 2 Pages

    | (TCO 2) Which of the following functions would you use to extract the from your records in the database?…

    • 363 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    b) 10 Convert the one table in the previous question to a relational database design. Fill each table in your…

    • 1445 Words
    • 6 Pages
    Powerful Essays
  • Satisfactory Essays

    Week2 Discussion2 DBMS

    • 480 Words
    • 3 Pages

    Given the business rule “an employee may have many degrees,” discuss its effect on attributes, entities, and relationships. (Hint: Remember what a multivalued attribute is and how it might be implemented.)…

    • 480 Words
    • 3 Pages
    Satisfactory Essays
  • Good Essays

    2, 2, 0, 5, 1, 4, 1, 3, 0, 0, 1, 4, 4, 0, 1, 4, 3, 4, 2, 1, 0…

    • 1337 Words
    • 6 Pages
    Good Essays
  • Powerful Essays

    Homework Assignment 5

    • 1706 Words
    • 7 Pages

    The four levels of state courts are as follows: The trial court of limited jurisdiction, the trial court of general jurisdiction which hears various kinds of cases, the intermediate appellate courts with a fixed maximum and minimum term of imprisonment and only hears appeals and the state courts of last report or Supreme Court of the state.…

    • 1706 Words
    • 7 Pages
    Powerful Essays
  • Satisfactory Essays

    SQL Queries

    • 423 Words
    • 2 Pages

    Query 2: Find the ClassID of all classes in which students are enrolled. The result should be a one column table, and no ClassID should appear more than once in that column.…

    • 423 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    Rn Application Sample

    • 4596 Words
    • 19 Pages

    40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76…

    • 4596 Words
    • 19 Pages
    Powerful Essays
  • Satisfactory Essays

    Name and Example Output

    • 492 Words
    • 2 Pages

    6) Find the names of students that live in one of the following 4 zipcodes. 60543, 60115, 60234, 60012. use in…

    • 492 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    CTS 2437 Final Exam

    • 630 Words
    • 4 Pages

    2. Select the course reference numbers and enrollments for courses with greater than the average enrollment of courses with more than 20 persons. Use a subquery.…

    • 630 Words
    • 4 Pages
    Satisfactory Essays
  • Satisfactory Essays

    6) Find the names of students that live in one of the following 4 zipcodes. 60543, 60115, 60234, 60012. use in…

    • 400 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Kudler Fine Foods wants to convert the Chart of Accounts sheet in Excel to an SQL database. In order to do so, it is important to format the excel data in proper SQL tables. Normalization plays an important part in placing data fields in proper tables.…

    • 480 Words
    • 2 Pages
    Good Essays

Related Topics