Warning: include() [function.include]: URL file-access is disabled in the server configuration in /nfs/cs/classes/www/06U/cis399oracle/lectures/week1.php on line 14

Warning: include(http://www.cs.uoregon.edu/classes/06U/cis399oracle/utility_functions.php) [function.include]: failed to open stream: no suitable wrapper could be found in /nfs/cs/classes/www/06U/cis399oracle/lectures/week1.php on line 14

Warning: include() [function.include]: Failed opening 'http://www.cs.uoregon.edu/classes/06U/cis399oracle/utility_functions.php' for inclusion (include_path='.:/private/apps/php-5.2.4/lib/php') in /nfs/cs/classes/www/06U/cis399oracle/lectures/week1.php on line 14

CIS 399 - Introduction to Oracle and SQL

Week 1 Lecture Notes

Monday, June 26 2006

  1. Introductions
  2. My history/qualifications
  3. Class history/introductions
  4. Syllabus overview

Tuesday, June 27 2006

  1. Relational Databases
    First Citation:
    Codd, E. F. 1970. A Relational Model of Data for Large Shared Data Banks. Communications of the ACM vol. 13, no. 6 (Jun. 1970), pp. 377-387. DOI= http://doi.acm.org/10.1145/362384.362685
  2. SQL = SEQueL = Structured English Query Language: Domain specific language for accessing databases
    First Citation (as SQUARE):
    Boyce, R. F., Chamberlin, D. D., Hammer, M. M., and King, W. F. 1973. Specifying queries as relational expressions. In Proceedings of the 1973 Meeting on Programming Languages and information Retrieval (Gaithersburg, Maryland, November 04 - 06, 1973). R. E. Nance, Ed. SIGPLAN '73. ACM Press, New York, NY, 31-47.
    DOI= http://doi.acm.org/10.1145/951762.951765
  3. Primary Keys
  4. Normalization
    1. First Normal Form (1NF): only atomic items in each column
    2. Second Normal Form (2NF): 1NF + all non-key items depend on the ENTIRE key
    3. Third Normal Form (3NF): 2NF + all non-key items depend on NOTHING BUT the key
    4. Boyce-Codd Normal Form (BCNF)*
    5. Fourth Normal Form (4NF)*
    6. Fifth Normal Form (5NF)*
    7. Domain/Key Normal Form (DKNF)*
    8. Sixth Normal Form (6NF)*
  5. Relationships and Foreign Keys
  6. Object Relational Model
  7. Oracle Overview
    1. data engine
    2. data dictionary
    3. security subsystem
    4. query processor
    5. administration tools
      1. Enterprise Manager
    6. forms and reports services
    7. Developer Suite
  8. SQL Plus
    1. ssh ix.cs.uoregon.edu
      1. Set up environment
        1. 'source /space/ordata/classfiles/sourceme.csh' if you are using csh
        2. 'source /space/ordata/classfiles/sourceme.bash' if you are using bash
      2. sqlplus
    2. or, remotely (such as SQLDeveloper):
      1. to download, go to: http://www.oracle.com/technology/software/products/sql/index.html
        (may require that you register to download), or get it from the instructor
      2. server: ix.cs.uoregon.edu
      3. SID: test1
      4. port: 1521

* - Beyond the scope of this course, but here for reference purposes

Wednesday, June 28 2006

  1. Announcements: books, accounts, homework
  2. Review of Primary/Foreign keys
  3. Overview of course databases
    1. Redwood Realty
      1. Primary example database - Real Estate Office
      2. Point out Primary, Foreign Keys, Composite Keys
      3. script: /space/ordata/classfiles/Chapter06/Databases/RedwoodRealty/BuildRedwood.sql
      4. Tables:
        1. ContactReason
        2. Customers
        3. Agents
        4. Listings
        5. Properties
        6. SaleStatus
        7. LicenseStatus
    2. Coffee Merchant
      1. Web-based coffee/tea business
      2. script: /space/ordata/classfiles/Chapter06/Databases/CoffeeMerchant/BuildCoffee.sql
      3. Tables:
        1. States
        2. Consumers
        3. Employees
        4. OrderLines
        5. Orders
        6. Inventory
        7. Countries
    3. Rowing Ventures
      1. Small database with unique terminology
      2. script: /space/ordata/classfiles/Chapter06/Databases/RowingVentures/BuildRowing.sql
      3. Tables:
        1. Boat
        2. Organization
        3. RaceTimes
        4. Race
        5. BoatCrew
        6. Person
    4. Broadcloth Clothing
      1. Large, complicated database
      2. script: /space/ordata/classfiles/Chapter06/Databases/Broadcloth/BuildClothing.sql
  4. SQL overview
    1. SQL99 fully recognized by Oracle
    2. Small variations among vendors
    3. Oracle extends SQL99 with SQL*Plus commands (only recognized by Oracle)
    4. Syntax rules:
      1. Statements terminated by semicolon
      2. Cannot abbreviate commands
      3. Separate words with some white space
      4. Not case-sensitive
      5. Comma used for separating column names
      6. Single quotes used for delimiting strings and dates
      7. Period used for delimiting schema/table/column names
      8. Double quote used for alternative column names
    5. Online Help: http://ora-code.com
    6. Scripts for the following examples
    7. Types of Commands:
      1. Query Statements
        1. SELECT
      2. Data Definition Language Statements (part 1)
        1. CREATE
        2. ALTER

Thursday, June 29 2006

  1. Announcements:
    1. scripts online: Scripts for the examples
    2. accounts fixed: you can create tables, etc.
    3. enterprise manager online
    4. isql*plus online: http://ix.cs.uoregon.edu:5560/isqlplus/
    5. university Oracle database (DAISY) - NOT available to students.
  2. SQL overview, continued...
    1. Types of Commands:
      1. Data Definition Language Statements (part 2)
        1. DROP
        2. RENAME
        3. TRUNCATE
      2. Data Manipulation Language Statements
        1. INSERT
        2. UPDATE
        3. DELETE
      3. Transaction Control Statements
        1. COMMIT
        2. ROLLBACK
        3. SAVEPOINT
      4. Data Control Language Statements
        1. GRANT
        2. REVOKE
  3. SQL*Plus commands
    1. DESCRIBE
    2. CLEAR SCREEN
    3. COLUMN
    4. SET PAGESIZE
    5. using variables
  4. Tablespaces, user accounts, etc. discussion

Answers to Questions / Clarifications

  1. DROP TABLE name CASCADE CONSTRAINTS PURGE;

    The CASCADE CONSTRAINTS option in Oracle does not drop tables with referential integrity constraints, it only drops the foreign key constraints. We will get into creating tables with foreign keys next week, but for now, here is an example in SQL*Plus:

    SQL> CREATE TABLE foo (
        id  INTEGER NOT NULL,
        name    VARCHAR(15),
        CONSTRAINT pk_foo_id PRIMARY KEY (id)
    );
    
    Table created.
    
    SQL> CREATE TABLE bar (
        id  INTEGER NOT NULL,
        name    VARCHAR(15),
        foo_id INTEGER,
        CONSTRAINT pk_bar_id PRIMARY KEY (id),
        FOREIGN KEY (foo_id) REFERENCES foo (id)
    );
    
    Table created.
    
    SQL> DROP TABLE foo;
    DROP TABLE foo
               *
    ERROR at line 1:
    ORA-02449: unique/primary keys in table referenced by foreign keys
    
    
    SQL> DROP TABLE foo CASCADE CONSTRAINTS;
    
    Table dropped.
    
    SQL>
    
  2. Oracle does NOT treat empty strings as NULL, despite the message we saw from SQL*Plus.

    Oracle USED TO treat empty strings the same as NULL, but not since version 9i (version before 10g). The message may have been a legacy message. I have seen conflicting information on this issue, but it would appear that in this case, Oracle equates an empty string to NULL.

  3. Related question from earlier in the week: Databases have a command to convert NULL values to actual values. In Oracle, that command is NVL. To use it:
    	SELECT NVL(column1,'abc') FROM table1;
    

    If column1 has NULL values, then this query will return the string 'abc' and not NULL.

  4. Question from earlier in the week: Oracle is an ACID-compliant DBMS. What is ACID compliance with regard to DBMSs?

    I would refer you to this site for a thorough explanation: http://cegt201.bradley.edu/projects/proj2003/equiprd/acid.html

  5. Another question from earlier this week: Can you create a table from another table?

    You can. You can even populate it with the data from the other table, too. To do that:

            CREATE TABLE NEWTABLENAME AS 
            SELECT * FROM OLDTABLENAME;
    
    In order to create the new table structure with no new data, add a WHERE clause to the statement which will always be *false*:
            CREATE TABLE NEWTABLENAME AS 
            SELECT * FROM OLDTABLENAME WHERE 1=2;
    

Back to Main Page

Valid XHTML 1.0 Strict