Primary key is an identifier that is used to identify an item/object/thing/row in that table. A foreign key is the primary key of another table.
A primary key is unique in its table. A foreign key does not need to be unique.
In a column of a table where it is being used to identify the item held in that table.
ID
On a related table.
table_name_id
- a
one-to-one
relationship. Spouse to Spouse. Marriage to Divorce. Person/Social Security Number. - a
one-to-many relationship
. House/Occupants. School/Students. - a
many-to-many relationship
. Musicans/Albums, Student/Classes, Videogames/Players
Test is used when tests are run by setting the environment variable to test. Development is used locally on your machine outside of tests. Production is used on a server in a production environment.
rails new some_project_name
Optional arguments: --database=postgresql
rails g model is equal to rails generate model, it takes an argument of the model that you'd like to generate, along with optional arguments regarding the data that you'd like to store in the model (e.g. first_name:text last_name:text, etc.)
It creates a new migration, a model, a model test, and a fixture.