šŸ’æ db

or, the ā€œJOIN me for some funā€ part.

tl;dr


xkcd: Exploits of a Momxkcd: Exploits of a Mom


i donā€™t have too many things to comment on as far as databases go. theyā€™re probably my weakest area. (iā€™m open to suggestions!)

recommendations

  • PostgreSQL: Recommendation used to be MySQL but PostgreSQL has definitely taken off community-wise.
    • a great service that provides Postgres as a service is Supabase.
  • Postico: you might have grown up on phpMyAdmin šŸ¤®. this is better.

ORM

prisma is a simple layer to have your code interface with your db.

on the other hand, there are arguments against using ORMā€™s since they can add cruft to your queries. as mentioned in the JS section about using frameworks, in general, using a higher-level wrapper doesnā€™t excuse you from learning how the underlying technologies works!


migrations

  • in your source code, a folder containing the scripts for updating schema from version 1 to your current version is recommended. (a tool for this would be great here!)
  • gh-ost. for more complicated db migrations.

quick note on NoSQL

again, iā€™m ill-equipped to talk about dbā€™s. but here are some options on NoSQL to explore if youā€™re into that kind of thing:


useful commands

(further reference on commands here.)

for when you canā€™t use the GUI and have to use the command line.

  • show databases ā€” like it says.
  • use [database] ā€” enter the context of a particular database.
  • describe [table] ā€” show the structure of a table.
  • show create table [table] ā€” show how a table is created. useful to get foreign key info.
  • select * from [table] where [conditions] ā€” select columns in a table.
  • insert into [table] ('[column1]', '[column2]') values ('[value1]', '[value2]') ā€” insert data into a table.
  • delete from [table] where [conditions] ā€” to remove rows in a table.
  • exit ā€” leave the program.