Relational Databases & Postgres

This lesson has an open issue for substantial revisions. I would advise not using it until that issue is resolved.

Projected Time

Total Time: 5-6 hours

Prerequisites

Motivation

To understand, query, and insert information into a relational database, a technology that is commonly used to store data for web and mobile applications. Also relational database model seems very feasible because of its tabular form which makes insertion and querying easy.

Use cases of SQL vs NoSQL databases

Objectives

Apprentices will be able to:

Specific Things to Learn

Materials

Education

Tools

Lesson

Relational Database Basics

Guided Practice

Independent Practice

(IMP: While working on the following activities you can refer back to the prerequisites at any point of time for better understanding.)

Activity #1

Think of data you’d like to store. Consider how to categorize this data– these categories can help define tables to create. Also consider relationships among these categories and what you might hope to accomplish using the data.

(i.e. What types of queries would you be most likely to execute? What types of questions would you want answered using the data available?)

Activity #2

Design your tables. Create an Entity Relationship diagram either on paper or using free software online. (Skim Omar El Gabry’s Medium post on Database Design if you haven’t already.)

Share your diagram with a peer and briefly explain how you arrived at that design.

Activity #3

Create tables based on your data models and diagrams.

Activity #4

Query some data. Ask a peer to challenge you with complex questions to query for based on your model – ideally questions that will require you to FILTER or GROUP BY by different properties.

Challenge

Schema design:

Solve the quizzes mentioned below

Check for Understanding

Supplemental Resources

Footnotes

1The word grok means “to understand”, usually with a connotation of “to understand deeply and intuitively.” It’s like a really deep feeling of “oh, I REALLY get it now.” People who love tech and sci-fi use this word and it can sometimes be an ingroup marker in programmer circles.