Code Monkey home page Code Monkey logo

apartment-database's Introduction

Apartment Database

  • Create a database called apartments
  • Using this database, create two tables, one for owners and one for propertys (table names shoud be lowercase and plural)
  • Keep this relationship in mind when designing your schema:
    • One owner can have many properties

Deliverable

  • Fork and clone this as normal
  • We don't have or need access to your local database - that's just for you to test it and come up with the right query! So, in order to turn this assignment in, put your SQL queries into part-1.sql, part-2.sql, and part-3.sql which can be found in the starter-code folder.
    • Your process will likely be running your query, and once it works, copying it into the appropriate file in the starter-code directory
  • Add, commit, and push your changes
  • Make a pull request!
  • Relax! ๐Ÿ˜Ž

Part 1: Create Tables

Place your answers in part-1.sql.

  • The owners table should consist of:
    • id (this should be the primary key as well as a unique number that increments automatically)
    • name - name of owner
    • age - age of owner
  • The properties table should consist of:
    • id (this should be the primary key as well as a unique number that increments automatically)
    • name - name of property
    • units - number of units
    • owner_id - reference to owner table

Part 2: Insert Data

Place your answers in part-2.sql.

  • Insert the following owners

    • Donald - age 29
    • John - age 33
    • Jane - age 43
    • Yuki - Age 67
    • Erin - Age 21
    • Siobhan - Age 55
    • Add 3 more people (you choose name / age)
  • Insert the following properties (you can pick and choose the property owners)

    • Archstone - 20 units
    • Zenith Hills - 10 units
    • Willowspring - 30 units
    • Ridgefield Bay - 5 units
    • Brookvista - 20 units
    • Goldendale - 15 units
    • Green Haven - 40 units
    • Fair Creek - 35 units
    • Parkview Pointe - 50 units
    • Royal Gardens Court - 45 units
    • Add 3 more properties (you choose name / units)

Part 3: Use Your Database

Write down the following sql statements that are required to solve the following tasks. Place your answers in part-3.sql.

  1. Show all the data in the owners table.
  2. Show the names of all owners.
  3. Show the ages of all of the owners in ascending order.
  4. Show the name of an owner whose name is Donald.
  5. Show the age of all owners who are older than 30.
  6. Show the name of all owners whose name starts with an E.
  7. Change Jane's age to 30.
  8. Change Jane's name to Janet.
  9. Delete the owner named Janet.
  10. Show the names of the first three owners in your owners table.
  11. Show the name of all owners whose name contains an a.
  12. Show all of the properties in alphabetical order that are not named Archstone and do not have an id of 3 or 5.
  13. Show the highest age of all owners.
  14. Show the highest age of owners who are under 30 and whose name contains an o. Limit to one result.
  15. Count the total number of properties where the owner_id is between 1 and 3.

Bonuses

These might require you to look up documentation online, or look at the next section in the notes. This is a bonus after all, so we're getting a little bit ahead!

  1. List all properties sorted by the owners names
  2. In the properties table change the name of the column "name" to "property_name".
  3. Add a new property to the owner with an id of 3.
Need a hint for 16? Look up the JOIN keyword. This allows you to pull data from two different tables based on fields they have in common.
Need a hint for 17? Look up documentation for ALTER TABLE. This allows you to change the schema (column name in this case).
Need a hint for 18? Look up INSERT INTO. Don't forget that the foreign key, `owner_id` needs to exist as an id in the owner table!

Licensing

  1. All content is licensed under a CC-BY-NC-SA 4.0 license.
  2. All software code is licensed under GNU GPLv3. For commercial use or alternative licensing, please contact [email protected].

apartment-database's People

Contributors

bhague1281 avatar brandiw avatar connorjclark avatar 009kings avatar samjyi95 avatar

Watchers

James Cloos 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.