[rails] - Databases and Rails Recap Quiz for Week 2
Object Relational Mapper
Create, Read , Update, Delete
class User < ActiveRecord::Base
end
------------------------------------
| Users Table |
+----+---------+-------------------+
| ID | Name | Movie |
|----+---------+-------------------|
| 1 | Richard | zoolander |
|----+---------+-------------------|
| 2 | Ruby | princess bride |
|----+---------+-------------------|
| 3 | Chris | sandlot |
+----+---------+-------------------|
A) Foreign
B) Primary
C) Public
D) Private
class Post < ActiveRecord::Base
has_many :comments
end
class Comment < ActiveRecord::Base
belongs_to :post
end
A post has properties :title, :author_name, and :body, a comment has properties :name & :body. Sketch out a posts table and a comments table including the primary and foreign keys. Use this data:
1) "John" wrote a post titled "I love dogs" with the content "woof", "richard" commented "that was great", susan commented "cats are better"
2) "Sara" wrote a post titled "cars are great" with the content " I think they are", "james" commented "they are"
Sketch this out so it looks like the users table above
puts "hello".class
# => __________________
puts {:bird => 'tweet'}.class
# => ___________________
class Adult
end
class Child < Adult
end
little_richie = Child.new
puts little_richie.class
# => ___________________
Hints:
select, where, count, from, *, =