Topics Covered: Relations; project sketching
When thinking about relations and foreign keys, it often helps to use an anology. Imagine you were your city or town's resident cat lady/cat guy and had decided to adopt 100 cats. Would it be more efficient for you to remember each of your cats, or for each cat simply to remember you? In Rails relations terms, you, as the owner, has_many
cats. Each cat belongs_to
you. Rather than you having to remember 100 foreign keys, it would make sense for each cat to instead simply store your foreign key.
Above we used the belongs_to
relation for our cats. When should we use the has_one
relation instead? Is there a difference between the two?
The most technical of the relations is undoubtedly many-to-many. Answer the following questions about the relation and check with a TA when you're done.
HTTP methods (also called verbs) are used to define actions to be performed on a particular resource. We will be dealing with four main verbs for the majority of this course. Below are brief descriptions of two of the most used verbs. See if you can match the GET and DELETE verbs with the proper definition.
We will also be dealing with the PUT and POST verbs in future lectures. Together, these four verbs correspond to create, read, update, and delete (or CRUD) operations. Although there are other verbs, e.g. OPTIONS and HEAD, these are used far more infrequently than the previous four.