Principles of GIS Fundamental database concepts – II Shaowen Wang CyberInfrastructure and Geospatial Information Laboratory (CIGI) Department of Geography and Geographic Information Science Department of Computer Science Department of Urban and Regional Planning National Center for Supercomputing Applications (NCSA) University of Illinois at Urbana-Champaign September 12, 2013
Connecting to DB % ssh username@geo480.cigi.uiuc.edu Login to DB Enter password Help: %psql --help Login to DB % psql -U geog480 -d geog480db
Some Postgres Commands List all accessible databases # \l Connect to a DB named 'geog480db' # \c geog480db List all the tables in current DB # \dt, # \d (show all relations) Quit # \q
SQL Commands Create Tables Delete table # create table test(key int, attr varchar(20), value float); Delete table # drop table test;
SQL Commands Insert a row Update table contents Delete rows # insert into test values(1, 'attr0', 100); Update table contents # update test set attr='attr1' where key=1; Delete rows # delete from test where key=1;
SQL Commands List contents of table # select * from test; # select * from test where attr='attr1';
Extended Entity-Relationship Model Sub-type Specialization Super-type Generalization Inheritance
Object-Orientation Object State Behavior Class Attributes Method
O-O Features Encapsulation Inheritance and polymorphism Reduces modeling complexity Promotes reuse Inheritance and polymorphism Combats impedance mismatch Metaphorical power
Relational Databases Attribute Tuple Relation scheme Relation
Relation ID Candidate key Primary key
Operations on Relations Project Restrict
Relational Algebra Derived relational operators Performance Join Natural join Performance
Extensible RDBMS RDBMS problems when handling spatial data Data structure Performance Search
Logging into the system % ssh netid@geog480.cigi.uiuc.edu Login name: netid Password: your password % psql -U username –d tutorial Login name: geog480 Password: same
End of This Class