0% found this document useful (0 votes)
114 views1 page

SQL Assignment

The document outlines two SQL assignments: 1) Querying a University database to return student names with over 100 credits, courses taken by student "Tanaka", instructor IDs and names who taught comp sci courses, and courses offered in both semesters. 2) Creating a Railway database from a DDL script, populating it with sample data, and writing queries to find station pairs within 20km, trains stopping at THANE, trains starting at MUMBAI, stations visited by "CST-AMR_LOCAL" train, and trains stopping at Thane before the 6th station.

Uploaded by

Ravi Purne
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
114 views1 page

SQL Assignment

The document outlines two SQL assignments: 1) Querying a University database to return student names with over 100 credits, courses taken by student "Tanaka", instructor IDs and names who taught comp sci courses, and courses offered in both semesters. 2) Creating a Railway database from a DDL script, populating it with sample data, and writing queries to find station pairs within 20km, trains stopping at THANE, trains starting at MUMBAI, stations visited by "CST-AMR_LOCAL" train, and trains stopping at Thane before the 6th station.

Uploaded by

Ravi Purne
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Assignment 1: Basic SQL

Statement: Write the following simple SQL Queries on the University Schema.

Find the names of all the students whose total credits are greater than 100 .

Find the course id and grades of all courses taken by any student named 'Tanaka'.

Find the ID and name of instructors who have taught a course in the Comp. Sci.
department, even if they are themselves not from the Comp. Sci. department. To test this
query, make sure you add appropriate data, and include the corresponding insert
statements along with your query.

Find the courses which are offered in both 'Fall' and 'Spring' semester (not necessarily in
the same year).

Optional:
Find the names of all the instructors from Comp. Sci. department.

Find the course id and titles of all courses taught by an instructor named 'Srinivasan'

Find names of instructors who have taught at least one course in Spring 2009.
Next Task:
Create the Railway schema using the commands in the Railway DDL script; the commands can
be copy-pasted into pgAdmin3. The DDL script also contains a description of the railway
Schema..
Insert sample data using the command in the file SampleRailwayData.
Try inserting more data into these tables. Refer to the populate script above for examples.
Statement : Write the following Queries for Railway Schema.

Find pairs of stations (station codes) that have a track (direct connection) with distance
less than 20Kms between them.

Find the IDs of all the trains which have a stop at THANE

Find the names of all trains that start at MUMBAI.

List all the stations in order of visit by the train 'CST-AMR_LOCAL'.


Find the name of the trains which have stop at Thane, before the 6th station in the route
of the train.

You might also like