Database Design StrategiesDatabase Design Strategies
Alinari
Relational Databases
◆ A relational database separates data by subject into different tables that are then related by common fields
◆ A relational database can ensure that your data is easily maintained over time
Relational Databases
✔Eliminates duplicate information✔Eases data entry and maintenance✔Eases data viewing and querying
Benefits of a Relational Database
Tables
◆ A table is the primary structure in a relational database, composed of fields and records
Tables
✔Table Name✔Table Category
– Data– Reference– Cross-Reference
✔Table Description
Important Elements of a Table
Tables
Tables that contain data about more than one subject
Tables that do not have a primary key
Primary Pitfalls to Avoid in Tables
Fields
◆ A field is an attribute, or characteristic, of the subject of the table
Fields
General Elements✔Field Name✔Table Name✔Field Description
Important Elements of a Field
Fields
Table Elements✔Type of Key
– None, Primary, Foreign, Alternate
✔Unique Value✔Required Value✔Data Type
– Boolean, Alphanumeric, Numeric, DateTime, Counter– Valid Characters, Length, Decimal Places
Important Elements of a Field
Fields
Data Entry Elements✔Field Label✔Values Entered By
– User, System
✔ Input Mask✔Display Format✔Default Value
Important Elements of a Field
Fields
Data Validation/Domain Elements✔Range of Allowed Values✔Set of Allowed Values✔Validation Rule
Important Elements of a Field
Fields
Query Elements✔Comparisons Allowed
– =, !=, >, >=, <, <=
✔Operations Allowed– Addition, Subtraction, Multiplication, Division
Important Elements of a Field
Fields
Fields containing multiple valuesRepeating data valuesFields containing calculated values
Primary Pitfalls to Avoid in Fields
Relationships
◆ A relationship is a connection between two tables
◆ A relationship can eliminate duplicate or redundant data
Relationships
✔Parent Table Name✔Child Table Name✔Relationship Type
– One-to-One (1:1)– One-to-Many (1:M)– Many-to-Many (M:M)
Important Elements of a Relationship
Relationships
Not using relationships; or creating all fields in a single table that should be broken into two or more related tables
Primary Pitfalls to Avoid in Relationships
Relationships
Finding one-to-many relationships in your data should signify to you that a relational database is the best choice for your data!In this case, a flat file will not accurately model your data.
Relational Data “Red Flag”
Normalization
◆ Normalization is the process of converting data from a flat file format into a proper relational database
◆ Normalization separates the fields from a large table into multiple, smaller, related tables by removing all unnecessary or duplicate fields
◆ Normalization ensures that each table represents only one subject
Normalization
All data is stored in a single tableA single record contains information on more
than one subjectA single record contains repeating fieldsMultiple records contain the same values for a
group of fields
Signs of a Non-Normalized Table
Normalization
◆ 1NF: Eliminate repeating groups
Normalization
✔Each table is identified with a primary key✔No table contains repeating values
Signs of a Database in First Normal Form
Normalization
◆ 1NF: Eliminate repeating groups◆ 2NF: Eliminate redundant data
Normalization
✔No table contains redundant data; or groups of repeated values for multiple records
Signs of a Database in Second Normal Form
Normalization
◆ 1NF: Eliminate repeating groups◆ 2NF: Eliminate redundant data◆ 3NF: Eliminate columns not dependent on the
key
Normalization
✔Each table contains only fields that are dependent on the primary key; or directly related to the subject of the table
Signs of a Database in Third Normal Form
Database Design Standards
◆ Database standards allow for the development of consistent, well-designed databases– Important for sharing data among multiple users– Important for merging data at a regional level
◆ A user familiar with the standards can open any database developed with those standards and have a good understanding of the tables
Database Design Standards
✔You can easily modify and maintain the structure of your tables and fields
✔You can easily modify the data in your database✔You can easily retrieve and compare information
from your database✔You can easily develop data entry windows and
more robust applications for your database
Advantages of a Well-Designed Database
Naming Standards
✔has a unique descriptive name that is meaningful to the entire organization
✔accurately, clearly, and unambiguously identifies the table subject or field characteristic
✔has the minimum number of words necessary to convey the table subject or field meaning
✔does not contain unknown acronyms or abbreviations
A good table or field name...
Naming Standards
✔does not contains words that describe the physical characteristics, such as “file”, “record”, “data”, or “table”
✔does not identify more than one table subject or field characteristic
✔uses the singular form of the name
A good table or field name...
Naming Standards
Sample EventsSample IDsite id
✔sample_event✔sample_id✔site_id
Poor Choices Better Choices
Avoid Spaces
Naming Standards
Site/Locationsphone #%MossCoverRain?project$
✔site_location✔phone_num✔moss_cover_percent✔ is_raining✔project_cost
Poor Choices Better Choices
Avoid Special Characters
Naming Standards
birddetectionsCLOUDCOVERdwarfsaplingheight
✔bird_detection✔cloud_cover✔dwarf_sapling_height_ft
Poor Choices Better Choices
Separate Words
Naming Standards
DIGITAL_PHOTOSampleStartTimeWindSpeed
✔digital_photo✔sample_start_time✔wind_speed_mph
Poor Choices Better Choices
Use Consistent Case
Naming Standards
life_stagesNumBirdsObserver_Names
✔ life_stage✔bird_count✔observer_name
Poor Choices Better Choices
Singularize Names
Naming Standards
smptrnidWtrCodcol_for_cur
✔sample_transect_id✔water_code✔ is_collected_for_curation
Poor Choices Better Choices
Avoid Unknown Abbreviations
Naming Standards
water_quality_evaluation_code
DescriptionOfGeomorphicDisturbance
smptrnid
✔h2o_quality_eval_code✔geomorphic_disturb_desc✔sample_transect_id
Poor Choices Better Choices
Limit Length
Naming Standards
AmphibianSizetree_sizeTree_Name
✔amphibian_length_in✔ tree_height_m✔ tree_species_name -or-
tree_common_name
Poor Choices Better Choices
Use Specific Names
Naming Standards
full_nameCityStateZipobservers_initials
✔ first_name, last_name✔city_name, state_code,
zip_code✔observer_initials
Poor Choices Better Choices
Ensure Single Values
Naming Standards
total_line_item_costplot_area_m2event_duration_time
✔ item_qty, unit_cost✔plot_width_m,
plot_height_m✔event_start_time,
event_end_time
Poor Choices Better Choices
Avoid Calculations
Naming Standards
avgcountcurrencydatedescexists
Poor Choices
Avoid Reserved Words
groupindexkeymaxmemomin
namenumberorderpercentpropertysection
setsumtimetypevalueyear
Naming a Table
◆ Data table prefix name with tbl_◆ Reference table prefix name with ref_◆ Cross-reference table prefix name with xref_
What category does this table fall into?
What noun or short phrase summarizes the contents of this table?◆ This should adhere to the naming standards
Naming a Table
✔ tbl_site✔ tbl_sample_event✔ ref_park✔ ref_precipitation✔xref_sample_observer
Good Choices
Naming a Field
What noun or short phrase summarizes the contents of this field?◆ This should adhere to the naming standards
What category describes the type of data in this field?
What unit of measure, if any, is required for this field?
Design Strategies Recap
◆ Standards add value to your data◆ Develop naming standards
– Formatting conventions– Naming conventions