When writing and submitting your assignments follow these requirements:
When asked to write a SQL statement you may use any editor you like so long as it stores the statements as plain text. This means you should not use a word processing program such as Microsoft Word. Simple editors such as Notepad or TextEdit, or a Eclipse code editor are fine.
There should be no errors or warnings in your code. SQL code that doesn't run doesn't get graded.
Put all your programs, testing, and discussion files into one zip file.
Follow the assignment instructions to the letter (e.g. name the various files t01.txt, t02.txt, etc.), as this assignment is auto-graded. If your SQL code files are not named correctly the auto-grading fails, and your assignment will be given a mark of 0.
These tasks use the DCRIS database. Test your SQL code either through your own DBMS connection, or with the SQL Practice page.
      These tasks are written for the most part in English and must be
      translated into SQL. Look at the DCRIS data to determine which ID numbers
      to use, if appropriate, and which columns to sort on. Requests to have
      rows "sorted by x then y", means to write the ORDER BY as ORDER BY X, Y.
    
Assignment 1 dealt with single tables and views, Assignment 2 dealt with joined tables and aggregation, and Assignment 3 dealt with subqueries. This assignment deals with metadata.
EXPLAIN.
      '...') around text. Do not use double
        quote ("..." at all.
      ;") at all.
      UNION, INTERSECT, or EXCEPT.
      *)
        columns.
      JOINs.
      JOIN … ON syntax, not alternatives
        such as USING.
      Some explanations:
      These functions use the information_schema to extract
      metadata from the DCRIS database. All table references must use information_schema
      as a prefix. For example, to query the TABLES table, you must
      refer to it as information_schema.TABLES.
    
      Further, we want only DCRIS information, so all queries must use the
      'dcris' TABLE_SCHEMA or CONSTRAINT_SCHEMA
      selections, i.e.:
 … WHERE … TABLE_SCHEMA =
        'dcris' …
 or
 … WHERE …
        CONSTRAINT_SCHEMA = 'dcris' …
    
Write a single SQL statement that:
selects the TABLE_NAME, TABLE_TYPE, TABLE_ROWS, and TABLE_COMMENT attributes from the TABLES table. Sort the results by the table name. Save the statement as .
This is an example of a subset of the results:
| TABLE_NAME | TABLE_TYPE | TABLE_ROWS | TABLE_COMMENT | 
|---|---|---|---|
| broad | BASE TABLE | 19 | Contains broad categories of security expertise. | 
selects the TABLE_NAME, TABLE_TYPE, TABLE_ROWS, and TABLE_COMMENT attributes from the TABLES table for tables with 100 or more rows. Sort the results by the table name. Save the statement as .
selects the TABLE_NAME, IS_NULLABLE, COLUMN_NAME, and DATA_TYPE attributes from the COLUMNS table. Sort the results by the table name and then column name. Save the statement as .
selects the TABLE_NAME, COLUMN_NAME, and DATA_TYPE attributes from the COLUMNS table for nullable columns. Sort the results by the table name and then column name. Save the statement as .
selects the CONSTRAINT_NAME, TABLE_NAME, and CONSTRAINT_TYPE attributes from the TABLE_CONSTRAINTS table. Sort the results by the constraint name and then table name. Save the statement as .
selects the CONSTRAINT_NAME and TABLE_NAME attributes from the TABLE_CONSTRAINTS table for UNIQUE constraints. Sort the results by the constraint name and then table name. Save the statement as .
          selects the CONSTRAINT_NAME, UPDATE_RULE, DELETE_RULE,
          TABLE_NAME, and REFERENCED_TABLE_NAME attributes
          from the
          
            TABLE_CONSTRAINTS
          
          
            REFERENTIAL_CONSTRAINTS
          
          table. Sort the results by the constraint name, then table name, then
          referenced table name. Save the statement as .
        
          selects the CONSTRAINT_NAME, UPDATE_RULE, TABLE_NAME,
          and REFERENCED_TABLE_NAME attributes from the
          
            TABLE_CONSTRAINTS
          
          
            REFERENTIAL_CONSTRAINTS
          
          table for constraints whose delete rule is not CASCADE. Sort
          the results by the constraint name, then table name, then referenced
          table name. Save the statement as .
        
selects the CONSTRAINT_NAME, TABLE_NAME, COLUMN_NAME, REFERENCED_TABLE_NAME, and REFERENCED_COLUMN_NAME attributes from the KEY_COLUMN_USAGE table. Sort the results by the table name and then column name. Save the statement as .
selects the TABLE_NAME, COLUMN_NAME, REFERENCED_TABLE_NAME, and REFERENCED_COLUMN_NAME attributes from the KEY_COLUMN_USAGE table for primary keys only. Sort the results by the table name and then column name. Save the statement as .