Giter VIP home page Giter VIP logo

thp_w5d3_chinookmusic's Introduction

Chinook Music db (100% finished)

A Ruby on rails project containing a music database (an Album model and a Track model). The data comes from the db>seeds.rb file.

Table of contents

General info

Made during The Hacking Project course on Week5 Day3.

Technologies

Project is created with

  • Ruby on Rails 5.2.3

Setup

First, go to the RoR project folder and type:

bundle install

then

rails c

Questions

Copy/paste the corresponding commands for each question in the console to display the answer.

๐Ÿ˜Š Easy level

  • What is the total number of Album objects contained in the database ?

    Album.count
  • Who is the author of the song "White Room"?

    Track.find_by(title: "White Room").artist
  • Which song lasts exactly 188133 milliseconds?

    Track.find_by(duration: 188133).title
  • Which band released the album "Use Your Illusion II" ?

    Album.find_by(title: "Use Your Illusion II").artist

๐Ÿคจ Medium level

  • How many albums have "Great" in their title?

    Album.where("title like ?", "%great%").count
  • eletes all the albums whose name contains "music".

    Album.where("title like ?", "%music%").destroy_all
  • How many albums are there written by AC/DC ?

    Album.where(artist: "AC/DC").count
  • How many songs last exactly 158589 milliseconds?

    Track.where(duration: 158589).count

๐Ÿ˜ตโ€๐Ÿ’ซ Difficult level

  • puts in console all the titles of AC/DC.

    Track.where(artist: "AC/DC").each do |track|
      puts track.title
    end
  • puts in console all the titles of the album "Let There Be Rock".

    Track.where(album: "Let There Be Rock").each do |track|
      puts track.title
    end
  • Calculate the total price of this album and its total duration.

    price = Track.where(album: "Let There Be Rock").sum(:price).round(2)
    duration = Track.where(album: "Let There Be Rock").sum(:duration)
    puts "#{price}, #{duration}"
  • Calculate the cost of the entire "Deep Purple" discography.

    Track.where(artist: "Deep Purple").sum(:price).round(2)
  • Modify (via a loop) all the titles of "Eric Clapton" so that they are displayed with "Britney Spears" in artist.

    Track.where(artist: "Eric Clapton").each do |track|
      track.update(artist: 'Britney Spears')
    end

thp_w5d3_chinookmusic's People

Contributors

demian-wicky avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.