MusicBox Schema Instructions
You are in charge of implementing the schema found in database-schema.png. You will implement the database using SQL. After it, you will drop the database and implement it again using Sequelize.
Before you start, create a user called “musicbox_app” with a password and CREATEDB privileges.
- SQL Practice
- Create a database called “musicbox” with owner “musicbox_app”
- Create the three tables in the schema “Genres”, “Albums” and “Artists”. Ensure that you capture the associations as foreign keys in your tables
- Create a sql file with seed data from
data-seed.txt
. Seed your database.
- Write the following queries in SQL
- Find the release date for all the albums by The Beatles.
- Find the artist for the album The Life of Pablo.
- Find all the albums along with their genres and artists.
- Sequelize Practice
- Drop the database called “musicbox”
- Use sequelize to initialize a project
- Update config/config.json with your “musicbox_app” user and the “musicbox” database
- Utilize sequelize_cli model:generate to create the three Models that correspond to every table in the schema. Remember that
sequelize model:generate
takes the singular model names (“Genre”, “Album” and “Artist”) and will generate a migration file with the pluralized table names (“Genres”, “Albums”, and “Artists”).
- Update the migrations files with validations and references
- Update the models with the associations in the schema
- Utilize sequelize-cli seed:generate to create seed files for each Model, and migrate the data in
data-seed.txt
into these files.
- Create a new file called
queries.js
in the top level of your application.
- Require your three models:
Using the Sequelize query syntax, prepare three functions that will return the values specified in these queries:
- Find the release date for all the albums by The Beatles.
- Find the artist for the album The Life of Pablo.
- Find all the albums along with their genres and artists.