background
loading scroll to btns
Back To Home
notes
3 min readSeptember 25, 2023

🪦 postgres

database
postgres
arch
api

what is postgres

  • postgres === postgreSQL
  • relational, SQL type database
  • k

why postgres

  • Availability - It is open source and free to use with any project
  • Common - It is a relational, SQL database which is the most common type of database right now
  • Popular and well tested - Postgres is a very popular database, and a common choice among enterprise software
  • Transferable skills - Because Postgres uses SQL, what you learn with Postgres is entirely transferable to working with a MySQL database or any other SQL database

the primary key column

  • it is most common to have an id column to be the primary key column for a table
  • id serial primary key is used to differentiate between different rows that may be identical
  • serial: the values will of the id column will be auto-incrementaing and one greater than the row previous
  • The Primary Key is a piece of information unique to each row, often an ID.
  • a table column whose values are
    • an auto incrementing number
    • guaranteed to be unique
  • a column with unique identifiers for each row in a table

the foreign key column

  • The Foreign Key is a column that relates each row to in the table to the primary key of another table
  • a reference to the primary key of another table

why foreign keys

  • create a relationship between data in one table with data in another table
  • to connect information from from different tables
  • allow queries to span multiple tables
  • Having a foreign key allows us to query for relationships between two tables of data

How to install postgres on arch

look at this useful gist

How enter the interactive terminal for working with Postgres.

By writing the command psql <username>

notes

  • data stored in postgres database doesn't have an order, it's not sorted, the data is just essentially in whatever order it was inserted into the table
  • su postgres This switches the terminal user from Root (the default) to postgres, which we will use to access the database.
  • psql postgres This will enter you into the interactive postgres terminal. Happy Experimenting!
  • Database names should use underscores
  • the power of data comes from being able to create and find relationship in the information we collect
  • Part of being a software developer (and this really applies for both front and back end developers) is being able to translate abstract ideas for features or apps into concrete data structures.
  • No where is this more true than in database design. It can be hard to take abstract ideas, identify their data needs, and meet those needs with tables and columns.

Comments