Giter Club home page Giter Club logo

record-collection-exercise's Introduction

Record Collection

Create and manipulate a SQLite database containing information about a record collection.

Part 1: Live Code

Together, we will examine and discuss the included csv file. We will determine the appropriate table structure and data types for all of the data it contains. This definition of structure and data types is known as the database schema.

After planning the schema, we will create a Ruby script (lib/setup_db.rb) to execute the necessary SQL code to create a database in database/record-collection.sqlite.

Now that we have a database ready to store data, extend lib/setup_db.rb to read the included csv file and insert the data it contains into the database after it creates a fresh database.

Each line in the csv should correspond to a single row in the database table.

Part 2: Chair-Pair Exercise

Now that we've got a database with both schema and data, create a new Ruby file (lib/queries.rb). This file will contain methods that query the database. I recommend wrapping these methods in a class or module to aid organization, modularity, and reusability. Don't get too hung up on organization yet though; that can be a refactor step later.

At the bottom of this README is a list of questions about the data. Each question will require at least one database query to answer. Any querying you do should be a part of a Ruby method. Here's an example:

  def count_releases
    # your code & queries here
  end

  # Question 1: How many albums are in the collection?
  "Answer 1: There are #{ count_releases } releases in the database."

The Questions

  1. How many albums are in the collection?
  2. How many unique artist entries are in the collection?
  3. What is the oldest (earliest release year) release in the database?
  4. Which album was most recently added to the collection?
  5. What was the first album added to the collection?
  6. How many albums were added to the collection in 2014?
  7. How many albums were released between 1970 and 1979?

Bonus Questions

The questions in this section are more difficult and will require some extra research to answer using just SQL queries.

  1. Which artist has the most albums in the collection?
  2. Which year has the most releases? How many albums were released in that year?
  3. What years between 1960 and 2010 have zero releases?

record-collection-exercise's People

Contributors

jnf avatar

Watchers

Anna 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.