Presentation is loading. Please wait.

Presentation is loading. Please wait.

Jeffery S. Horsburgh Hydroinformatics Fall 2014

Similar presentations


Presentation on theme: "Jeffery S. Horsburgh Hydroinformatics Fall 2014"— Presentation transcript:

1 Jeffery S. Horsburgh Hydroinformatics Fall 2014
Data Model Design Jeffery S. Horsburgh Hydroinformatics Fall 2014 This work was funded by National Science Foundation Grants EPS and EPS

2 Objectives Identify and describe important entities and relationships to model data Develop data models to represent, organize, and store data Design and use relational databases to organize, store, and manipulate data

3 Data Modeling Goal – make sure all data objects required by a database are completely and accurately represented Data model design – the blueprint for creating a physical implementation of a database

4 Data Modeling Terms Entity – a class of real world objects having common attributes (e.g., sites, variables, methods). Attribute – A characteristic or property of an entity (site name, latitude, longitude) Relationship – an association between two or more entities Cardinality – the number of entities on either end of a relationship (one-to-one, one-to-many, many-to-many, etc.)

5 Data Modeling Exercise
Consider: What is the “entity”? What are the “attributes” of the entity?

6 Data Modeling Exercise
What is the entity? What are the attributes?

7 Data Modeling Exercise
What is the entity? What are the attributes?

8 Data Modeling Exercise
What are the relationships? Grows In Apple Apple Tree Orchard Grows On

9 Data Modeling Exercise
What are the relationships? Grows In Apple Apple Tree Orchard Grows On What about the business rules?

10 Assignment 2 Data Multiple Monitoring Sites
1 or More Time Series Per Sensor Multiple Sensors at Each Site

11 Assignment 2 Data

12 Assignment 2 A researcher recently deployed several instruments to continuously monitor streamflow and water quality at two sites in the Little Bear River, Cache Valley, Utah.  The instruments report measurements in numerous datalogger and metadata files that the researcher must now regularly retrieve, organize, quality-control/quality-check, aggregate, and manipulate before s/he can perform further analysis.   Design a data model to represent the data and its associated metadata Use MySQL Workbench to create an entity relationship diagram of your data model

13 Data Model Requirements
What is the information/data domain that you are modeling? What are the 20 queries that you want to do? e.g., “Give me simultaneous observations of turbidity and TSS collected during the spring snowmelt period so I can develop a regression in R.” What software do you want (have) to use? How do you want to share the data?

14 Data Model Design Our focus – relational data model design
Three stages: Conceptual data model Logical data model Physical data model

15 Conceptual Data Model (AKA – The Information Model)
High-level description of the data domain Does not constrain how that description is mapped to an actual implementation in software There may be many mappings Relational database Object model XML schema, etc.

16 Apple/Tree/Orchard Conceptual Model
Grows In Apple Apple Tree Orchard Grows On

17 Hydrologic Time Series
An organization operates a network of monitoring sites. At each site they collect data for a number of time series, and each time series contains a time series of observations

18 Conceptual Data Model Entities Relationships
Defines scope of the domain Defines and organizes data requirements Defines entities and relationships among them Entities Site 1 TimeSeries * Observations 1 Relationships *

19 Defining Entities and Relationships
Instead of beginning with this: Sometimes its easier to write statements: Many TimeSeries are measured at a Site. Each TimeSeries contains one or more Observations. The nouns become entities and the verbs become relationships. Site TimeSeries 1 * 1 Observations *

20 Exercise: Conceptual Data Model

21 Logical Data Model Technology independent
Contains more detail than the Conceptual Data Model Considered by many to be just an expanded conceptual data model Defines Entities AND their attributes Relationships AND cardinality Constraints (think Business Rules) Generally completed as a documented Entity Relationship (ER) Model or diagram

22 Example: ODM Logical Data Model ER Diagram

23 Entity Relationship Diagram
Documentation of the structure of the data Used to communicate the design Serve as the basis for data model implementation

24 Entity Relationship Diagram (Relation Database Context)
Entities effectively become tables Attributes describe entities and become fields (columns) in tables Relationships link tables on a common attribute or “key” and become formal constraints (part of the business rules)

25 Entities and Attributes
What are the attributes of a monitoring site? Attributes Values Site Name: Little Bear River near Wellsville Site Code: USU-LBR-Wellsville Latitude: Longitude: Elevation: m State: Utah County: Cache Description: Attached to SR101 bridge. Site Type: Stream Relational Model: All instances of an entity have the same attributes Entity = Monitoring Site

26 ER Diagram Entity Notation
Entity Name Data Type Attributes Entity

27 ER Diagram Relationship Notation
Multiple notation systems are used Each software program is a little different Most common is “Crows Foot” Crows Foot Alternative 0 .. * 1 .. * 1 .. 1 0 .. 1

28 Relationship Cardinality and Participation
Cardinality: maximum number of times an instance in one entity can be associated with instances in the related entity Participation: minimum number of times an instance in one entity can be associated with instances in the related entity

29 Cardinality Maximum number of times an instance of an entity can be associated with instances of a related entity Can ONLY have values of 1 or many Located closest to the entity in Crows Foot notation

30 Participation Minimum number of times an instance in one entity can be associated with instances in the related entity Indicates whether an instance of an entity MUST participate in the relationship Can ONLY have the values of 0 or 1

31 Mapping Cardinality and Participation
Apple Grows_on AppleTree A1 A2 A3 A4 A5 A6 R1 R2 R3 R4 R5 R6 T1 T2 T3

32 Reading Cardinality and Participation

33 Relationship Examples
Left to Right: A site has 0 or more time series of data. Right to Left: A time series is measured at 1 and only 1 site. Left to Right: A variable has 0 or more time series of data. Right to Left: A time series can have 1 and only 1 variable.

34 Relationship Examples
Left to Right: A TimeSeries has 1 or more Observations. Right to Left: An Observation belongs to 1 and only 1 TimeSeries. Left to Right: An Observation has 0 or more Qualifiers. Right to Left: A Qualifier describes 0 or more Observations.

35 Primary and Foreign Keys
Each row in a table should have an attribute that is a persistent, unique identifier – the “Primary Key” Primary key in “parent” table Foreign key in “child” table

36 Primary and Foreign Key Example
OrchardID OwnerName Area_acres 1 John Appleseed 5.5 2 Daryl Appleseed 15 Orchards AppleTreeID Species Size DatePlanted OrchardID 1 Honeycrisp 5 4/15/2010 2 6 3 Apple Trees AppleID Color Weight AppleTreeID 1 Green 200 2 180 3 195 Apples

37 Primary and Foreign Keys
Usually consist of integer values MUST be the same data type in parent and child tables

38 Creating an ER Diagram Using MySQL Workbench

39 Summary Data model design is a 3 step process – conceptual, logical, physical (future topic) Conceptual and logical data models can be expressed using Entity Relationship (ER) diagrams ER diagrams capture the entities, attributes, and relationships to model your information domain ER diagrams are a powerful way to document the design of your data model

40 Steps in Data Model Design
Identify entities Identify relationships among entities Determine the cardinality and participation of relationships Designate keys / identifiers for entities List attributes of entities Identify constraints and business rules

41 Exercise Work alone or in groups of 2-3
Use MySQL Workbench to begin creating an Entity Relationship diagram Identify entities Specify attributes Create relationships

42 Assignment 2 Data Multiple Monitoring Sites
1 or More Time Series Per Sensor Multiple Sensors at Each Site


Download ppt "Jeffery S. Horsburgh Hydroinformatics Fall 2014"

Similar presentations


Ads by Google