Giter Club home page Giter Club logo

u3_lab_sql_joins's Introduction

Real Estate Fun with Joins!

Real Estate

Overview

In this lab, we'll be getting in some practice using SQL Joins by working with a real estate database.

Getting Started

  • fork and clone
  • cd into the directory

Setup

You have been given a schema file and a seed file that will be used to build a real estate database. The database will have four tables:

buildings
apartments
tenants
doormen

These represent some of the apartment buildings on Gersh.com. Before getting started, take some time to go through the schema file to understand what fields, data types each table requires and how the tables are related. This is important!

Part 1- Create database and run schema

Run the schema.sql file using psql -f schema.sql. This will create your database and set up the schema.

Part 2 - Populate database

Run the seed.sql file using psql -f seed.sql to insert the records into the database. You DO NOT need to edit the seed file! It has been set up for you.

The database is named real_estate_db. Connect to it in psql to test your queries.

Assignment - Queries

In the real_estate_queries.sql file, write queries to do the following:

  • Retrieve all info on the first 10 tenants (Hint: use LIMIT)
  • Retrieve the name, age, and gender of the first 10 tenants
  • Retrieve all info on all tenants older than 65
  • Retrieve all info on all tenants in apartment with id 20
  • Retrieve all info on all tenants in apartment with ids 20 or 21
  • Retrieve the names of all doormen and the address where they work
  • Delete all tenants whose age is greater than 65
  • Change all doormen from building 3 to work night shifts.
  • Create one new tenant, put them in any apartment you want
  • Find just the ids for all apartments for building with id of 2
  • Find all info for apartments in building number 3 whose price is greater than $2300
  • Geriatric Birthday! Update all tenants whose age is 90 to be 91

Old

NOTE: The real_estate_queries.sql file already has the questions inside (commented out) with a line for you to write your queries. You can run psql -d real_estate_db -f real_estate_queries.sql to run your queries, comment out the prior queries so they don't run again once completed. q to exit the prompt.

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.