DOC PREVIEW
NU EECS 339 - Homework 1

This preview shows page 1 out of 2 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

SetupQueriesIntroduction to Database SystemsHomework 1Due: April 9, 2019 at 11:59 PM1 SetupFor this problem set, you will have to setup your own database with PostgreSQL, a widely used open sourcerelational database system. To install and set up PostgresSQL, follow the instructions here (under Setup). Onceyou have installed Postgres, download the ‘university.pgd’ file from Canvas and run the following commands:% createdb university% psql university < Downloads/university.pgdNote that, ‘Downloads/university.pgd’ should be the path to your university.pgd file. We are asking you to setup Postgres on your machine in order to show you how real world database development works. You will mostlikely encounter problems setting up your environment. If you are having issues and find yourself spending morethan an hour installing Postgres, please ask questions on Piazza or stop by office hours.PgAdmin (Optional DB Management UI)pgAdmin is the most popular and feature rich Open Source administration and development platform for Post-greSQL. It has a user interface to manage databases, view tables (data) and run queries over a PostgreSQLinstallation. You can download PgAdmin from here: https://www.pgadmin.org/download/ (please follow theinstructions accordingly).After installing, you have to create a server with host address: ‘localhost’, port: 5432, username: ‘postgres’,and a name, e.g., ‘my-db’. You can then view tables and data of the problem set by going to servers→my-db→databases→university→schemas→public→tables. More details are available here:https://www.pgadmin.org/docs/pgadmin4/dev/query tool.html.2 QueriesConsider the following schema:student(sid, sname, sex, age, year, gpa)dept(dname, numphds)prof(pname, dname)course(cno, cname, dname)major(dname, sid)section(dname, cno, sectno, pname)enroll(sid, grade, dname, cno, sectno)For each of the following statements, write both the relational algebra version and the SQL version. If it isnot possible to write the relational algebra, explain why not. For the SQL version, run your queries using Post-gres. Include the output of your SQL queries with each answer. You may find these queries easier to write ifyou express them as relational algebra first and then write the SQL.(0.25 point for relational algebra + 0.25 point for SQL = 0.5 point each)1. Print the details (i.e., course no. and name) of the courses which are offered from a department havingmore than 65 PhD students.EECS 339 Introduction to Database Systems Rogers, Spring 20192. Print the name(s) of the male students with highest GPA.3. For each class having a name that starts with ‘Intro’, print the cno, sectno, average age and max gpa ofthe students enrolled.4. Find the names of the students who have taken all courses offered by Civil Engineering department.5. Print the names of the departments, which offer at least one course having one or more enrolled studentswho are under 18 years old.6. For each department that has less than eight female majors with an average age of 23 or less, print thename of the department, the average GPA of its majors and the number of PhD students there.7. Find the names of all the students, whose grade in ‘Advanced City Planning’ is lower than the grade in‘City Planning’.8. Print the details (id, name, and major) of the students who took courses offered by multiple departments.9. Print the age difference between the oldest and youngest Computer Science major students.10. For each department that has one or more majors with a GPA under 1.0, print the name of the departmentand the average GPA of its


View Full Document

NU EECS 339 - Homework 1

Download Homework 1
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Homework 1 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Homework 1 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?