Week 5 - Database design

Relational Databases

Primary Keys and Foreign Keys

Constraints

Database normalization

PostgreSQL setup

Joins

Java and databases

Practice

Assignment

Back end Track

Relational Databases

There are many ways to store data, but the most popular way is by using a Relational Database. As a reminder, here’s what you learned previously. The basics are simple:

This last one is probably the trickiest part. Let's start with an example of a school, where students enroll in courses, and courses are taught by instructors. The school keeps track of all their students, courses, and instructors, in a (properly normalized, we'll get to what that is in a bit) relational database. The tables look like this:

Student table:

studentId studentName
101 Jan
102 Henk
103 Piet
104 Jan

Course table

courseName instructor
Databases Dr. Bakker
Algorithms Dr. ten Brink
Networks Dr. Jansen

Enrollment table

studentId course finalGrade
101 Databases 6.5
101 Algorithms 8.5
102 Databases 7.0
103 Networks 6.0
103 Databases 8.0
104 Networks 8.5
104 Algorithms 7.5

Let’s take a closer look at the anatomy of these tables in the next chapter.


The HackYourFuture curriculum is licensed under CC BY-NC-SA 4.0 *https://hackyourfuture.net/*

CC BY-NC-SA 4.0 Icons

Built with ❤️ by the HackYourFuture community · Thank you, contributors

Found a mistake or have a suggestion? Let us know in the feedback form.

JASPER test