Chap 4 Spatial DBMS - Exercise PostgreSQL
Chap 4 Spatial DBMS - Exercise PostgreSQL
The installer will add a PostgreSQL 9.1 menu to your Start menu.
Navigate to the PostgreSQL 9.1 menu item and run PgAdmin III.
Double click on the “PostgreSQL Database Server” tree entry. You will be
prompted for the super user password to connect to the “postgres” database.
Now you are connected to server.
Navigate to the “Databases” section of the database tree and open “Edit → New
Object → New Database”.Add a new database
named “StudentDB”, with “postgres” as the owner. “postgres” as the template.
Now StudentDB database has been created in Databases section.
3 SQL QUERY EXAMPLE
SELECT *
FROM FACULTY;
Query 6: Find out student which are female or greater than 20 year
Query 8: Find all three credit course and list them alphabetically by course name in
descending order.
SELECT COURSENAME
FROM COURSE
WHERE NUMCREDIT = 3
ORDER BY DEPARTMENT DESC;
Query 9: Gives the Name of Faculty and their salary whose salary becomes 60,000
after the 15 percent increment.
Query 10: Find out student which are not register for any course.
SELECT STUDENTNO
FROM ENROLL
WHERE GRADE IS NULL;
Query 13: Gives the average salary of faculty whose salaries are more 40,000.
Query 15: Find the names of student who are in COURSENO CEL747, and got GRADE
=F;
SELECT STUDENTNAME
FROM STUDENT s JOIN ENROLL e ON e.STUDENTNO = s.STUDENTNO
WHERE COURSENO = ‘CEL747’ AND GRADE = ‘F’;
Query 16: In which course did males’ student get ‘A’ grade?
Query 17: List the name of all FACULTY ordered alphabetically descending by
department.
Query 18: How many students are there in Prof. Gosain GIS’s class?
4 TUTORIAL
4.1 DESIGN A DATABASE
Design a database to keep track of the grades that students receive in their courses Current
Year Current semester. The following items to be included in the database:
4.2 QUERIES
Queries are a fundamental means of accessing and displaying data from tables. Queries can
access a single table or multiple tables.
Do Following Query
1. Find all the students belonging to CE who have obtained “A” and “B” grade in “CExxx”
subject. Result should have Student name, Registration Number, Hostel Name, Course
Name and Grade.
2. Find the Faculty belonging to CE and the courses they take. Result should have Faculty
ID, Faculty name, Department name, Course code, course name.
3. Find out the course floated in CE department and the faculty teaching the respected
course. Query should result in Course code, course name, semester, faculty ID, faculty
Name.
4. Which student from “xx” hostel has taken CE course? Should include student ID,
student name, Hostel name, Course name, Course code, faculty taking the course, grade
the student has obtained in this course.