Quiz: Make Changes to your Database

Test your knowledge on how to make changes to your database.

1

Examine the following migration:

create table("compositions") do add :title, :string, null: false 
add :year, :integer, null: false add :artist_id, 
references("artists"), null: false timestamps() end

What’s the advantage of using references for the artist_id column rather than just :integer?

A)

Ecto will automatically set up our schema for us.

B)

The database will be able to infer the name of the column automatically.

C)

Ecto will tell the database to add a foreign key constraint.

D)

It’s easier to read.

Question 1 of 50 attempted

Get hands-on with 1400+ tech skills courses.