Database Design

Designing a database is something that makes you sound like a badass, but it's actually pretty easy to pick up. It can get very complicated very quickly if you want it to, but you can basically hang out in the chill zone forever if you want to.

Relational Databses

We'll be working with relational databases in this tutorial -- specifically, SQL Databases (SQL stands for Structured Query Language).

Tables

A Relational Database stores information in tables.

For example, let's say for our Instagram clone, we wanted to allow people to make posts. We'd make a Post table. Each row would represent a specific instance of a post and each column would represent a characteristic of that post. For example:

Post

imageURL caption postedBy date id
http://image_url1 what an amazing day armanh mm/dd/yyyy 1
http://image_url2 I love cats rnvarma mm/dd/yyyy 2
http://image_url3 Vegan Life is dope! anonymous_butterfly mm/dd/yyyy 3

Then, let's say we wanted to allow people to like the posts. This becomes a bit more complex.

We need to keep track of a couple of things:

  1. Who likes the post
    1. simple! We do it the same way we kept track of the posted_by in the Post Table.
  2. What post are we liking?
    1. How do we keep track of this? Something called a Foreign Key

Basically, this is what the table would look like:

Like

likedBy Post
user1 2
user2 1
user3 1
user4 1

results matching ""

    No results matching ""