(20 Points)1. Identify the key (candidate keys) for each of the following relations and normalize until they are in BCNF. Assume the following dependencies where relevant:
A ---> B A ---> C A ---> L B ---> C A,F ---> G G ---> F A,F ---> K a) R1 (A,B,C) b) R2 (A,B,D) c) R3 (A,G,F)
(30 Points) 2. Assume the following:
Answer the following questions about accessing an SQL database using the classes in java.sql package:
(30 Pts.) 3. Assume the following relations:
Write the SQL queries for the following:
EXEC SQL BEGIN DECLARE SECTION; int credit; int count; int id_num; EXEC SQL END DECLARE SECTION; EXEC SQL DECLARE list_courses CURSOR FOR SELECT cdesc,credits,count(sec#) FROM course,section WHERE course.c#=section.c# and fss#=:id_num main() { /* assume code for connecting is here as well as the SQL statement for trapping errors */ printf("Please Enter Faculty ID:");scanf("%d",&id_num); /* open cursor */ EXEC SQL OPEN list_courses; /* set trap for end of data */ EXEC SQL WHENEVER NOT FOUND GOTO end_of_fetch; /* loop until fetch fails, control is then transferred to end_of_fetch. */ for ( ; ; ) { EXEC SQL FETCH list_courses INTO :desc,:credit,:count; if (credit>3 && count>1) { desc.arr[desc.len]='\0'; /* null terminate desc */ printf("%-30s\n", desc.arr); } } end_of_fetch: EXEC SQL CLOSE list_courses; EXEC SQL COMMIT WORK RELEASE; /* Log off the database. */ printf("\nHave a good day!\n\n"); exit(0); }