Duplicate of DataCamp Live Training - Analyzing NASA Planetary Exploration Budgets in SQL (student)
  • AI Chat
  • Code
  • Report
  • Beta
    Spinner

    Analyzing NASA Planetary Exploration Budgets in SQL

    For much of the last 60 years, NASA has been at the forefront of exploring our solar system. In this live training, we'll see how much money they spent to do this.

    For expensive science projects, not least those funded with public money, the price of conducting research is a huge consideration, so budgeting is important.

    Here, we'll use a cleaned up version of the public dataset provided by the The Planetary Society.

    Task 1: What is the total cost of all planetary missions over all time?

    A good first step in any budgetary analysis is to determine how much money has been spent in total.

    For this, we need the mission_budgets table. Each row represents the cost in a fiscal year, of one aspect of a project for one mission. There are 5 columns:

    • mission: The name of the mission.
    • fiscal_year: The year, for accounting purposes.
    • cost_type: Fine-grained aspect of the project, e.g., "Spacecraft".
    • cost_group: Broader aspect of the project, e.g., "Development/Implementation".
    • cost_MUSD: Cost in million US dollars.

    Instructions

    • Calculate the total cost of all missions over all time as total_cost_MUSD.
    Unknown integration
    DataFrameavailable as
    df
    variable
    -- Calculate the total cost of all missions over all time
    SELECT SUM("cost_MUSD") AS total_cost_MUSD
    	FROM mission_budgets
    This query is taking long to finish...Consider adding a LIMIT clause or switching to Query mode to preview the result.

    Task 2: What happens when you adjust for inflation?

    Due to inflation, costs in the 1960s are not directly equivalent to those in the 2020s. We need to adjust for inflation in order to get a cost in current currency.

    Correction factors are available in the inflation table. Each row represents an inflation adjustment for a time period relative to today. ther are two columns.

    • fiscal_year: The year, for accounting purposes. Note that in 1976, inflation was especially high, so two values are provided. "1976" represents the start of the year, and "1976TQ" represents the third quarter onwards.
    • inflation_adjustment: Multiply currency values from the past time by this number to get current currency values.

    Instructions

    • Join the mission_budgets table to the inflation table on the fiscal year.
    • Calculate the total cost of all missions over all time, adjusted for inflation as adjusted_total_cost_MUSD.
    Unknown integration
    DataFrameavailable as
    df
    variable
    -- Calculate the total cost of all missions over all time, adjusted for inflation
    SELECT SUM("cost_MUSD" * inflation_adjustment) AS adjusted_total_cost_MUSD
    	FROM mission_budgets
        LEFT JOIN inflation
        	USING(fiscal_year)
        	--ON mission_budgets.fiscal_year = inflation.fiscal_year
    This query is taking long to finish...Consider adding a LIMIT clause or switching to Query mode to preview the result.

    Task 3: Which was the most expensive mission?

    The biggest, grandest missions make headlines, but at some point, someone always asks questions about how much things cost, and the biggest budgets are the first place people look for cost savings. Knowing which is the most expensive project is an essential task for anyone responsible for a budget.

    Instructions

    • Group the budgets by mission, and calculate the total cost for each mission.
    • Get the mission with the highest total cost.
    Unknown integration
    DataFrameavailable as
    df
    variable
    -- Get the mission with the highest total cost
    SELECT mission, SUM("cost_MUSD" * inflation_adjustment) AS adjusted_total_cost_MUSD
    	FROM mission_budgets
        LEFT JOIN inflation
        	USING(fiscal_year)
        GROUP BY mission
        ORDER BY adjusted_total_cost_MUSD DESC
        LIMIT 1
    This query is taking long to finish...Consider adding a LIMIT clause or switching to Query mode to preview the result.

    Task 4: How much was spent each year?