Massachusetts Institute of Technology - Department of Urban Studies and Planning


11.521
Spatial Database Management and Advanced Geographic Information Systems
11.523
Fundamentals of Spatial Database Management

Advanced Queries, Referential Integrity, and Relational Database Design

28 February 2008


Administrative

Today:


More examples of advanced query construction

Examining Views and other system tables: Suppose we have taken advantage of Oracle to save complex queries as views that can be imported into ArcMap. How can we find the definition of a view?

describe all_views

select max(TEXT_LENGTH) from ALL_VIEWS where owner = 'JF';
 where view_name = 'MADENSITY';
  grant select on madensity to public;
  create public synonym v_madensity for madensity

Computing the percentage of East Boston parcels that are triple-deckers (LU=R3)

Compute same percentage in a single SQL query:

select 100 * n.r3_count / d.all_lu 
  from (select count(LU) R3_count from bos05eb where LU = 'R3') n,
       (select count(LU) all_lu from bos05eb) d; 

 


Lab #3 lookup example: spelling corrections for Boston parcel ownership

Build lookup table for Boston parcel ownership


Introduction to Relational Database Design (based on Lecture by Tom Grayson)

Review: The Relational Model
Review: Qualities of a Good Database Design
Introduction to Entity-Relationship Modeling
E-R Modeling Process
Database Normalization
Review: Database Design Rules of Thumb
Enforcing Referential Integrity in Oracle

[Optional: Correlated Updates - examples of UPDATEs only for SELECTed rows]

Review: The Relational Model

Review: Qualities of a Good Database Design

Introduction to Entity-Relationship Modeling

E-R Modeling Process

From E-R Model to Database Design

Database Normalization

Much of formal database design is focused on normalizing the database and ensuring that the design conforms to a level of normalization (e.g., first normal form, second normal form, etc.). Although there are higher normal forms, Third Normal Form is generally considered good enough for typical applications. Normalization generally involves taking a design with fewer tables and many columns and transforming it into a design with more tables with fewer columns -- after conducting some tests and applying some rules. First normal forms requires that there be no multi-valued attributes. Second Normal Form requires that non-key fields must be dependent upon the entire key. Third Normal Form prohibits transitive dependencies (whereby a non-key attribute is dependent on another non-key attribute). Here is some online sites with useful database management concepts and tips including some good discussion of database normalization: and first, second, and third normal form:

Review: Database Design Rules of Thumb

Enforcing Referential Integrity in Oracle

See Tom Grayson's notes regarding the syntax of SQL statements to define primary and foreign keys and to constrain table manipulation in order to enforce referential integrity - that is, to keep you from making changes to tables that destroy their internal consistency.

 


Home | Syllabus | Lectures | Labs | CRN | 37-312 lab | MIT

For more information about this page, please contact the 11.521 Staff Mailing List <11.521staff@MIT.EDU>.
Written February, 2001 (Tom Grayson), Last Modified 28 February 2008 (jf)