Fall 10, Dr. Zhen Jiang Project #5 SQL

Total Page:16

File Type:pdf, Size:1020Kb

Fall 10, Dr. Zhen Jiang Project #5 SQL

CST221 Fall 10, Dr. Zhen Jiang Project #5 SQL

Due day is posted on D2L. Late submission is not acceptable.

Consider the following data base. Fac contains info about faculty Student contains info about students There is a one to many relationship between Faculty and students (each faculty has 0 or more advisees, and each student is advised by one fac. member) Fac AdvNum Name Rank Office Yrs Worked A10 Jones Full Prof B406 12 A20 Smith Asst Prof Y310 4 A30 Bradly Full Prof X234 10 A40 Anders Instructor X208 2 A50 Baker Asst Prof B402 14

Student StNum StName age Major class gpa AdvNum s100 Al 20BIO JR 2.5A40 s18 Matt 21ENG JR 3.7A30 S24 Nicole 24ENG SR 3.2A10 s28 Jenny 25BIO FR 3.2A30 s34 Bob 20CSC FR 2.5A40 s39 Amanda 30CSC JR 2.6A20 s49 Cindy 30CSC JR 3.6A40 s54 Fred 20BIO FR 1.5A50 s55 Pam 30ENG SO 3.6A10 s56 Sam 22CSC SO 4A50 s65 Alisha 20BIO SO 2.9A10 s71 Hal 40CSC SR 2.8A40 s77 John 17CSC FR 3A50 s78 Al 19ENG SR 3A10 s88 Ed 25CSC JR 3.5A50 s96 Lisa 30ENG FR 3.5A20 s99 Sam 45BIO JR 2A30

FR represents freshman, SO- sophomore JR- Junior and SR-Senior

Evaluation: Create Sql queries directly for each of these. Save each as QA , QB .....

QA) For each student who is a Freshman in Biology, list number, name, age, and gpa QB) For each student who has a GPA <2 , list their gpa, age, number, name, the name and number of their advisor. QC) For each student who is a Freshman, list their number, name, age, and a value called “Expected age as a Senior” (which shows their age three years from now). For example student s34 would have this row of data stNum StName age Expected age as a Senior s34 Bob 20 23

QD)List all faculty (number, and name) who reside in Building ‘B’ (office number starts with the letter ‘B’) QE)For each advNum, list advNum and the average gpa and count of their Freshman advisees QF)For each Major, list the Major and the avg age, min age and max age for that major The column headings should be “average age” “youngest” “oldest” QG) For each student who is a senior, list stNum, name, gpa, advisor number, advisor name and rank. Order your result stName QH) For each class, list class and the number of students under 25 years old, include the average gpa of these students QI)For each advisor, list number, name, rank, and list of their advisees (stNum , stName and gpa) who have gpa below 3.0. QJ)List the advisor number, of any advisor who has more than one student with a GPA above 3. Include a count of these students. QK) For the faculty member named ‘Jones’ (list name, number and rank) and all their advisees (number and name and age) who are not seniors. (sort the result by advisee names) QL) List the number, name and gpa, for all students who have a higher than average gpa. QM)List the number, name, and age, for all students who are in Majors with more than 5 members ======After you create each query in Access. Copy the SQL code for that query and paste it into a word document. Also paste the result of the query into your word document

For example Suppose you were asked to list the number, name and age of all students >25 You would hand in the following copy of your SQL code, and a copy of the query result

Select stNum,stName,age from Student where age>25;

QA StNum StName s49 Cindy s55 Pam s71 Hal s96 Lisa s99 Sam s39 Amanda

Upload a copy of your word document with your SQL queries to D2L

Recommended publications