Which of the following is an attribute or collection of attributes in one table that uniquely identifies a row of another table?

This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters

1. Why do they call it a relational database?
A relational database is a database that has a collection of tables of data items, all of which is formally described and organized according to the relational model. In the relational model, each table schema must identify a column or group of columns, called the primary key, to uniquely identify each row. A relationship can then be established between each row in the table and a row in another table by creating a foreign key, a column or group of columns in one table that points to the primary key of another table.
2. What is SQL?
SQL (Structured Query Language) is a special-purpose programming language designed for managing data held in a relational database management system (RDBMS).
3. There are two predominant views into a relational database. What are they, and how are they different?
4. In a table, what do we call the column that serves as the main identifier for a row of data? We're looking for the general database term, not the column name.
The primary key
5. What is a foreign key, and how is it used?
Column that is used to create a relation with another table.
6. At a high level, describe the ActiveRecord pattern. This has nothing to do with Rails, but the actual pattern that ActiveRecord uses to perform its ORM duties.
Active record is an approach to accessing data in a database. A database table or view is wrapped into a class which means that an object instance maps to a single row in the table.
7. If there's an ActiveRecord model called "CrazyMonkey", what should the table name be?
crazy_monkeys
8. If I'm building a 1:M association between Project and Issue, what will the model associations and foreign key be?
projects table
has_many :issues
issues table
belongs to :user
9. Given this code
class Zoo < ActiveRecord::Base
has_many :animals
end
o What do you expect the other model to be and what does database schema look like?
class Animal < ActiveRecord::Base
Belongs_to :zoo
end
o What are the methods that are now available to a zoo to call related to animals?
Getter and setter
o How do I create an animal called "jumpster" in a zoo called "San Diego Zoo"?
Set the foreign key for jumpster equal to the primary key for San Diego Zoo
10. What is mass assignment? What's the non-mass assignment way of setting values?
Assigning all columns for a row at once. Alternative is to use the getter and setter
11. What does this code do? Animal.first
Retrieve the first row
12. If I have a table called "animals" with columns called "name", and a model called Animal, how do I instantiate an animal object with name set to "Joe". Which methods makes sure it saves to the database?
my_animal = Animal.new
my_animal.name = “Joe”
my_animal.save
13. How does a M:M association work at the database level?
One row of table 1 is related to many rows of table 2
One row of table 2 is related to many rows of table 1
14. What are the two ways to support a M:M association at the ActiveRecord model level? Pros and cons of each approach?
Using the has_and_belong_to relation or using a join table. A join table is more flexible since it can contain other columns.
15. Suppose we have a User model and a Group model, and we have a M:M association all set up. How do we associate the two?
User Model
has_many :memberships
has_many :groups through :memberships
Group Model
has_many :memberships
has_many :users through :memberships

Which of the following is an attribute or collection of attributes in one table that?

A key is an attribute or set of attributes which helps us in uniquely identifying the rows of a table. It also helps in establishing relationship among tables.

Which of the following is attribute in one table that uniquely identifies a row of another table?

An attribute that uniquely identifies the rows of a table is known as the key.

Which of the following describes a collection of one or more attributes that together uniquely identify a record?

The correct answer is Super Key. There is always one primary key in a table for each record which is used to uniquely identify that record. KEYS in DBMS is an attribute or set of attributes that help you to identify a row(tuple) in a relation(table).

Which of the following uniquely identifies each row in the table using the values in two or more columns?

A primary key is the column or columns that contain values that uniquely identify each row in a table.