PDF Version Available
This document is also available in PDF format: week8beyondSQL.pdf
The PDF version includes bookmarks for easy navigation and is optimized for printing.
Accessibility Notice
This document is also available in HTML format at:
Link: https://aholdengouveia.name/AdvData/labs/week8beyondSQL.html
The HTML version provides enhanced accessibility features including keyboard navigation, screen reader support, responsive design, dark mode support, and high contrast options.
Request
Request: DATA-9025
Requested by: Head of the data team
Data: Your database from the SQL Review lab, and your schema from the Database Schema lab
Background
Your design has been approved, so now it's time to build it. Your manager wants your data moved out of the one big table and into the tables in your schema, cleaned up along the way, with a record of every change. The team is also starting to look at other kinds of databases, so your manager wants a quick comparison of relational and non-relational databases for your data.
Learning Outcomes
By the end of this lab, you will be able to:
- Organize a data set into multiple tables based on a schema, and load it into a database
- Clean up data, and record each change in a cleanup log
- Decide which ways to reduce repeated data to use, and justify each decision with research
- Compare relational and non-relational databases for a data set
Lab Instructions
Start from the database you turned in for the SQL Review lab, and add your lookup table from the SQL Review Part 2 lab if it's part of your schema. Books are my example data only, so use your own data set. If you want to switch to a different data set, email me first. Switching means redoing the work from earlier labs for your new data set, so it adds a lot of work. The switching checklist (linked under Resources) lists what you'd need to redo.
I suggest SandboxSQL, linked under Resources. Use Load a Database to open the database file you turned in for the SQL Review lab. You can use a different tool if you prefer, as long as you turn in a database file, not a CSV file or a spreadsheet. SandboxSQL doesn't always keep your work if you close the page, so export often. If you need to load your raw data again, use my CSV to Database Converter (linked under Resources).
Name your files with version numbers, such as version 1.0 and 2.0 for big changes, and 1.1 and 1.2 for small ones (for example, Database1.1). Don't use names like Database Final and Database Final REALLY final.
Screenshots
Several parts of this lab ask for a screenshot. Each screenshot should have your name, term, and year. One of the easiest ways to do that is make a text document with your name and term/year on your computer and save it to use all term. Any screenshots that don't include this information won't be counted.
Part 1: Decide How to Reduce Repeated Data
In the Database Schema lab, you made at least 2 suggestions for reducing repeated data.
- For each suggestion, decide whether to use it now, save it for later, or not use it at all.
- Research each decision, using at least 2 reliable sources in total. Check each source with the CRAAP test (linked under Resources), and cite each one with a link.
- Explain each decision in a few sentences, using your research.
- If your decisions change your schema, update it. Put anything new or changed in bold, and add a short note saying what changed and why.
Part 2: Build Your Tables
- Create each table in your schema, with its primary key and any foreign keys.
- Copy your data from your one big table into the new tables. One way is INSERT with SELECT. For example, this fills a publishers table with one row for each different publisher in my book data:
The SQLite documentation for INSERT is linked under Resources.INSERT INTO publishers (publisher_name) SELECT DISTINCT publisher FROM books; - Keep your original big table until everything is copied over and checked. Then you can delete it, or keep it as a copy of the raw data.
- Take a screenshot of your database structure showing all your tables, and a screenshot of one of your new tables with data in it.
Part 3: Clean Up Your Data
Fix the problems you listed in the quality notes on your data card, and any others you find. Record every fix in a cleanup log, following the sample cleanup log (linked under Resources). For each entry, give the date, whether it was before, during, or after loading, the table and column, the problem, the change you made, why, and how many rows were affected. If you checked something and decided not to change it, log that too.
Part 4: Export Your Database
- Export your whole database as a file. In SandboxSQL, use the Export button, which saves it as a .sqlite file.
- Run this query, which lists the CREATE TABLE command for every table in your database:
Take a screenshot of the results.SELECT name, sql FROM sqlite_master WHERE type = 'table'; - Pick one CREATE TABLE command, and explain in your own words what each part of it does, including the keys.
Part 5: Relational or Non-Relational?
Make a pro and con list or table for keeping your data in a relational database, and for moving it to a non-relational database. Give at least 3 pros and 3 cons for each, specific to your data.
Acceptance Criteria
This request is done when:
- Every suggestion from the Database Schema lab has a decision, backed by research from at least 2 cited sources that you've checked with the CRAAP test
- Every table in your schema exists in your database, with its primary key and any foreign keys
- Your data is in the new tables, and your screenshots show the tables and data
- Every change to your data is in your cleanup log, including the number of rows affected
- Your exported database includes all your tables, and you've explained one CREATE TABLE command
- At least 3 pros and 3 cons each for relational and non-relational, specific to your data
- Every screenshot follows the screenshot rules
Deliverables
Two files:
- A document that includes Part 1, your decisions, research, and any schema changes; Part 2, your screenshots; Part 3, your cleanup log; Part 4, your screenshot and your explanation of one CREATE TABLE command; and Part 5, your pros and cons
- Your exported database file
Audience: the head of the data team.
Resources
References, a video, a PowerPoint and some notes are available at my website Link: https://www.aholdengouveia.name/AdvData/BeyondSQL.html
Sample cleanup log, showing the format to follow Link: https://www.aholdengouveia.name/AdvData/labs/SampleCleanupLog.txt
SQLite documentation for INSERT Link: https://www.sqlite.org/lang_insert.html
My CSV to Database Converter, which makes a database file from your CSV file Link: https://www.aholdengouveia.name/AdvData/labs/csv-to-database.html
Suggested tool: SandboxSQL, free, runs in your browser, and saves your database as a .sqlite file with its Export button Link: https://www.sandboxsql.com/
Optional, if you'd rather install a tool: DB Browser for SQLite, which can import a CSV file directly Link: https://sqlitebrowser.org/
The CRAAP test, for checking your sources Link: https://web.archive.org/web/20250814000638/https://guides.lib.uchicago.edu/c.php?g=1241077&p=9082343
My guide to evaluating sources Link: https://www.aholdengouveia.name/Howtos/Sourceeval/sourceEvaluation.html
Switching checklist, if you want to change data sets Link: https://www.aholdengouveia.name/AdvData/labs/SwitchingDataSets.txt