Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 of 42 Lecture 5 Data Model Design Jeffery S. Horsburgh Hydroinformatics Fall 2013 This work was funded by National Science Foundation Grants EPS

Similar presentations


Presentation on theme: "1 of 42 Lecture 5 Data Model Design Jeffery S. Horsburgh Hydroinformatics Fall 2013 This work was funded by National Science Foundation Grants EPS"— Presentation transcript:

1 1 of 42 Lecture 5 Data Model Design Jeffery S. Horsburgh Hydroinformatics Fall 2013 This work was funded by National Science Foundation Grants EPS 1135482 and EPS 1208732

2 2 of 42 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 3 of 42 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 4 of 42 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 5 of 42 Data Modeling Exercise Consider: – What is the “entity”? – What are the “attributes” of the entity?

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

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

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

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

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

11 11 of 42 Assignment 2 Data

12 12 of 42 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 13 of 42 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 14 of 42 Data Model Design Our focus – relational data model design Three stages: – Conceptual data model – Logical data model – Physical data model

15 15 of 42 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 16 of 42 Apple/Tree/Orchard Conceptual Model Apple Apple Tree Orchard Grows On Grows In

17 17 of 42 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 18 of 42 Conceptual Data Model Defines scope of the domain Defines and organizes data requirements Defines entities and relationships among them Site TimeSeries Observations 1 1 * * Entities Relationships

19 19 of 42 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 DataValues. The nouns become entities and the verbs become relationships. Site TimeSeries Observations 1 1 * *

20 20 of 42 Exercise: Conceptual Data Model

21 21 of 42 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 Generally completed as a documented Entity Relationship (ER) Model or diagram

22 22 of 42 Example: ODM Logical Data Model ER Diagram

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

24 24 of 42 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 25 of 42 Entities and Attributes What are the attributes of a monitoring site? Entity = Monitoring Site AttributesValues Site Name:Little Bear River near Wellsville Site Code:USU-LBR-Wellsville Latitude:41.643457 Longitude: -111.917649 Elevation: 1365 m State: Utah County: Cache Description: Attached to SR101 bridge. Site Type: Stream Relational Model: All instances of an entity have the same attributes

26 26 of 42 ER Diagram Entity Notation Attributes Entity Entity Name Data Type

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

28 28 of 42 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 29 of 42 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 30 of 42 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 31 of 42 Mapping Cardinality and Participation A1 A2 A3 A4 A5 A6 R1 R2 R3 R4 R5 R6 T1 T2 T3 AppleGrows_onAppleTree

32 32 of 42 Reading Cardinality and Participation

33 33 of 42 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 34 of 42 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 35 of 42 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 36 of 42 Primary and Foreign Key Example OrchardIDOwnerNameArea_acres 1John Appleseed5.5 2Daryl Appleseed15 AppleTreeIDSpeciesSizeDatePlantedOrchardID 1Honeycris p 54/15/20101 2Honeycris p 64/15/20101 3Honeycris p 34/15/20101 AppleIDColorWeightAppleTreeID 1Green2002 2Green1802 3Green1952 Orchards Apple Trees Apples

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

38 38 of 42 Creating an ER Diagram Using MySQL Workbench

39 39 of 42 Summary Data model design is a 3 step process – conceptual, logical, physical (next time) 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 40 of 42 Steps in Data Model Design 1.Identify entities 2.Identify relationships among entities 3.Determine the cardinality and participation of relationships 4.Designate keys / identifiers for entities 5.List attributes of entities 6.Identify constraints and business rules

41 41 of 42 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 42 of 42 Assignment 2 Data Multiple Monitoring Sites Multiple Sensors at Each Site 1 or More Time Series Per Sensor


Download ppt "1 of 42 Lecture 5 Data Model Design Jeffery S. Horsburgh Hydroinformatics Fall 2013 This work was funded by National Science Foundation Grants EPS"

Similar presentations


Ads by Google