Skip to content

Latest commit

 

History

History
205 lines (133 loc) · 9.34 KB

Building_Database_Tables.md

File metadata and controls

205 lines (133 loc) · 9.34 KB

Data Management

For Scientific Research

stanza body copyPhoto: © Stanza. Used with permission.

Session 5: Building Database Tables

Today we will use an example to review data models and create a database design using MySQL Workbench.

mysql wb splash

Start MySQL Workbench

Please open up MySQL Workbench so you can follow along.

opening mysql wb from xfce


We will use the design to automatically create the database tables.

As we design the database on the screen, you should also create the same database design in MySQL Workbench on your own computer.

Example: Sample Testing

Structured Narrative:

  1. Technician prepares prepared sample from sample using preparation method.

  2. Technician performs lab test on prepared sample using test method.

The entities have been italicized. We will assume that all necessary computer interactions (i.e. data entry steps) are included in the "prepares" and "performs" actions.

Identifying the Entities and Relationhsips

And putting them in a table...

Entity Relationship Entity Relationship Entity
Technician prepares prepared sample from sample
-> using preparation method
Technician performs lab test on prepared sample
-> using test method

Conceptual Data Model

lab testing conceptualdata model erd

Canine AT-AT Model

at at dogPhoto: John Nolan / Katie Mello / Star Wars Blog

Logical Data Model

Working together, we will create this EER diagram in MySQL Workbench.

lab testing eer diagram

Discussion

Explain our EER diagram.

at at dog costume creationPhoto: John Nolan / Katie Mello / Star Wars Blog

Generating Database Tables

Using the "Forward Engineer" feature, we can save a schema file and create tables. The tables can be explored in "SQL Editor".

lab testing eer tables

Logical Data Model Modified

In order to use these tables for generating a website with a framework (like CakePHP), we will need to make our table names plural to conform with the framework's conventions.

lab testing eer diagram

Logical Data Model Expanded

By adding more tables, we can track additional entities:

  • Measurement Units
  • Sample Type (Matrix)
  • Clients
  • Sample Disposal
  • Instruments
  • Analytes

And even so, we still are not tracking containers or "splits".


lab testing eer diagraml

Database with Web Interface

cake php lab clients

With a few shell commands, we can create a functioning web application from our database schema. More on that later!

In the Coming Sessions...

  • Structured Query Language (SQL)
  • Database Applications and Web Frameworks
  • Embedded SQL

Action Items (videos, readings, and tasks)

watching
readings
tasks
  • Normalize your Logical Data Model (ERD) in MySQL WB
  • "Forward Engineer" your ERD to create a schema file and tables
  • Post your schema and EER diagram(s) in your project wiki
  • Refer to the example in the "Data Management" project wiki

See Also

Questions and Comments

questionImage: © Nevit Dilmen / Wikimedia

Some Parting Words

If you welcome chaos, chaos is gonna organize itself for you, in front of your own eyes.

--Philippe Petit on Creative Chaos

tightrope walkerImage: Wiros / Wikimedia