2 Three-Step Database Design Database applications are modeled using a three-step design processConceptual-datatypes, relationships and constraints(ER model)Logical-mapping to a Relational model and associated query language(Relational Algebra)Physical-file structures, indexing,
3 Example Application Domain Database design is for a specific application domainOften a requirements document is availableDesigners discuss requirements with end-users as neededWe will use a simple spatial application domainto illustrate concepts in conceptual and logical data modelsto illustrate translation of conceptual DM to logical DMSpatial application domainA state-park consists of forests.A forest is a collection of forest-stands of different speciesState-Park is accessed by roads and has a managerState-Park has facilitiesRiver runs through state-park and supplies water to the facilities
4 Conceptual DM: The ER Model 3 basic conceptsEntities have an independent conceptual or physical existence.Examples: Forest, Road, Manager, ...Entities are characterized by AttributesExample: Forest has attributes of name, elevation, etc.An Entity interacts with another Entity through relationships.Road allow access to Forest interiors.This relationship may be name “Accesses”Comparison with Object model of spatial informationEntities are collections of attributes are like objectsHowever ER model does not permit general user defined operationsRelationships are not directly supported in Object modelbut may be simulated via operations
5 Relationship TypesRelationships can be categorized bycardinality constraintsother properties, e.g. number of participating entitiesBinary relationship: two entities participateTypes of Cardinality constraints for binary relationshipsOne-One: An instance of an entity relates to a unique instance of other entity.Many-One: Many instances of an entity relate to an instance of an other.Many-Many: Many instances of one entity relate to multiple instances of another.Exercise: Identify type of cardinality constraint for following:Many facilities belong to a forest. Each facility belong to one forest.A manager manages 1 forest. Each forest has 1 manager.A river supplies water to many facilities. A facility gets water from many rivers.
6 ER Diagrams Graphical Notation ER Diagrams are graphic representation of ER modelsSeveral different graphic notation are usedWe use a simple notation summarized belowExample ER Diagram for Forest exampl in next slideConceptSymbolEntitiesAttributesMulti-valued AttributesRelationshipsCardinality of Relationship1:1, M:1, M:N
7 ER Diagram for “State-Park” [ SLAYT ]ER Diagram for “State-Park”Exercise:List the entities, attributes, relationships in this ER diagramIdentify cardinality constraint for each relationship.How many roads “Accesses” a “Forest_stand”? (one or many)
8 Logical Data Model: The Relational Model Relational model is based on set theoryMain conceptsDomain: a set of values for a simple attributeRelation: cross-product of a set of domainsRepresents a table, i.e. homogeneous collection of rows (tuples)The set of columns (i.e. attributes) are same for each rowComparison to concepts in conceptual data modelRelations are similar to but not identical to entitiesDomains are similar to attributes
9 Relational Schema Schema of a Relation Relational schema of a database Enumerates columns, identifies primary key and foreign keys.Primary Key :one or more attributes uniquely identify each row within a tableForeign keysR’s attributes which form primary key of another relation SValue of a foreign key in any tuple of R match values in some row of SRelational schema of a databasecollection of schemas of all relations in the databaseExample: next slideA blue print summary drawing of the database table structuresAllows analysis of storage costs, data redundancy, querying capabilitiesSome databases were designed as relational schema in 1980sNowadays, databases are designed as E R models and relational schema is generated via CASE tools
10 Relational Schema Example Identify relations withprimary keysforeign keysother attributesCompare with ER diagramCASE – Computer-aidedSoftware Engineering tools,Oracle designer, ERwinQuestion: Road-crosses-River is missing???
11 Relational Schema for “Point”, “Line”, “Polygon” and “Elevation” Relational model restricts attribute domainssimple atomic values, e.g. a numberDisallows complex values (e.g. polygons) for columnsComplex values need to be decomposed into simpler domainsA polygon may be decomposed into edges and verticesString
12 More on Relational Model Integrity ConstraintsKey: Every relation has a primary key.Entity Integrity: Value of primary key in a row is never undefinedReferential Integrity: Value of an attribute of a Foreign Key must appear as a value in the primary key of another relationship or must be null.Normal Forms (NF) for Relational schemaReduce data redundancy and facilitate querying1st NF: Each column in a relation contains an atomic value.2nd and 3rd NF: Values of non-key attributes are fully determined by the values of the primary key, only the primary key, and nothing but the primary key.Other normal forms exists but are seldom usedTranslating a well-designed ER model yields a relational schema in 3rd NFsatisfying definition of 1st, 2nd and 3rd normal forms
13 Mapping ER to Relational Highlights of translation rulesEntity becomes RelationAttributes become columns in the relationMulti-valued attributes become a new relationincludes foreign key to link to relation for the entityRelationships (1:1, 1:N) become foreign keysM:N Relationships become a relationcontaining foreign keys or relations from participating entitiesExample and ExerciseIdentify the relational schema components forentity Facility, its attributes and its relationships
14 Extending ER with Spatial Concepts MotivationER Model is based on discrete sets with no implicit relationshipsSpatial data comes from a continuous set with implicit relationshipsAny pair of spatial entities has relationships like distance, direction, …Explicitly drawing all spatial relationshipclutters ER diagramgenerates additional tables in relational schemaMisses implicit constraints in spatial relationships (e.g. partition)PictogramsLabel spatial entities along with their spatial data typesAllows inference of spatial relationships and constraintsReduces clutter in ER diagram and relational schemaExample: Next slide is simpler than earlier slide
16 Specifying Pictograms Grammar based approachRewrite rulelike English syntax diagramsClasses of pictogramsEntity pictogramsbasic: point, line, polygoncollection of basic...Relationship pictogramspartition, network
17 Entity Pictograms: Basic shapes, Collections Multi shape:
18 Entity Pictograms: Derived and Alternate Shapes Derived shape example: A road is represented as a polygon for constructionor as a line for navigation- For certain conditions, for example, depending on the scale, a city center point can be represented as a polygon
19 Conceptual Data Modeling with UML MotivationER Model does not allow user defined operationsObject oriented software development uses UMLUML stands for Unified Modeling LanguageIt is a standard consisting of several diagramsclass diagrams are most relevant for data modelingUML class diagrams conceptsAttributes are simple or composite propertiesMethods represent operations, functions and proceduresClass is a collection of attributes and methodsRelationship relate classes
20 UML Class Diagram with Pictograms: Example Exercise: Identify classes, attributes, methods, relationships in this Figure.
21 Comparing UML Class Diagrams to ER Diagrams Concepts in UML class diagram vs. those in ER diagramsClass without methods is an EntityAttributes are common in both modelsUML does not have key attributes and integrity constraintsER does not have methodsRelationships properties are richer in EREntities in ER diagram relate to datasets, but UML class diagramcan contain classes which have little to do with data
22 Summary Spatial Information modeling can be classed into Field based and Object basedField based for modeling smoothly varying entities, like rainfallObject based for modeling discrete entities, like countryA data model is a high level description of the datait can help in early analysis of storage cost, data qualityDatabase are designed in 3-stepsConceptual, Logical and PhysicalPictograms can simplify Conceptual data models