Skip to content

Instantly share code, notes, and snippets.

@harrisonmalone
Last active May 25, 2020 02:21
Show Gist options
  • Save harrisonmalone/3c40f0d400950b217021df540c0525b9 to your computer and use it in GitHub Desktop.
Save harrisonmalone/3c40f0d400950b217021df540c0525b9 to your computer and use it in GitHub Desktop.
Q9
tables
rows
attributes
datatypes dependent on the type of rdbms, in postgres you have bigint, text, varchar etc
how do you format the db in rails? migrations
constraints
tables can relate to each other through their attributes
---
Q10
https://en.wikipedia.org/wiki/Data_integrity
data integrity in a relational db is data being accurate and consistent
you use things like validators in rails for user input to ensure that no bad data is stored in a db
some of the things that enforce consistency are:
primary keys, the value is always unique, it can be an auto incrementing number, uuids
foreign keys, attributes that we have in our records that connect different tables together, refers to a primary key value
columns are for each specific table
---
Q11
the way in which we can manipulate records in a relational database model is through SQL
SQL definiton
the way in which we can add records to a relational db is through the INSERT INTO command etc
---
https://stackoverflow.com/questions/2307283/what-does-olog-n-mean-exactly
Q12
O(n log n)
quicksort
mergesort
bubblesort
---
Q13
binary search O(log n)
linear search O(n)
[1,2,3].each do |num|
if num == 2
return num
end
end
---
Q14
a.
software https://stackshare.io/airbnb/airbnb
b.
hardware
make some assumptions
they're using amazon EC2 which is a cloud offering for running virtual machines
the hardware that the virtual machines is running on is a server in an amazon data center
c.
when we deploy the web server code is always running on a virtual machine
if you were using continuous deployment you could update your code an any time
rails controller, how that connects to the database
how is sass or js compiled by rails
the client side is sending http requests to our rails app, our rails app is sending back http responses
d.
airbnb uses a relational db
the data would be structured into different tables
and each table would contain a number of rows
document db => the data would structured into collections with individual documents nested in these collections
e.
users
profiles
homes
locations
invoices
categories
payments
f.
users have many homes
user has one profile
homes have one location
homes have many invoices
home has many categories
category has many homes
g.
https://dbdiagram.io/
make a diagram
take a screenshot and put it into your submission
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment