Database Systems CSE 5260 Spring 2005
Database Schema #1 Branch (Branch_Name, Branch_City, Assets) Customer (Customer_Name, SS#, Street, City, State, Zip_Code) Account (Account_Number, Branch_Name, Balance) Loan (Loan_Number, Branch_Name, Amount) Depositor (SS#, Account_Number) Borrower (SS#, Loan_Number)
Problem #1 (15 pts) Refer to the Database Schema #1. a) SQL - Find the names of all branches in the loan relations. Remove duplicate branch names. b) SQL Find all customers who have both a loan and an account at the bank. c) SQL Find the customer names and their loan numbers for all customers having a loan at some branch.
Problem #2 (15 pts) Consider the following relational schemes fro storing information associated with a hospital. Patient (SS#, name, policy#) Visit (SS#, date-admitted, time-admitted) Doctor (DrSS#, name, specialty) Log (SS#, DrSS#, test_type, date, result) Provide a relational algebra expression for each of the following. a) A list of the social security numbers for those patients who had a test for asthma on the same date that they were admitted. b) A list of the social security numbers or those patients who visited (admitted) the hospital on 01/01/05. c) A list of the social security numbers of those patients who have each had a test for asthma and a test for anemia, but never had a test for bronchitis.
Problem #3 (15 pts) Suppose that a database is to be developed for the information associated with a university. Information stored must include basic student and faculty information, which students are advised by which faculty, which students are registered for which courses, and which faculty teach which courses. Note that in this university students can register for one or more courses, each student has exactly one advisor, each faculty member advises one or more students, every faculty member teaches one or more courses, and every faculty member has a unique office. In addition, every student, faculty, and course has a unique id number. Finally, a history of student grades is also to be maintained. The history must contain a record of a grade for each course taken by a student. Furthermore, if a student repeats a class multiple times, the history must contain an entry for each and every time the student takes the class. Suppose that the following relational schemes are identified from the above description. Student (student_id, city, street, major) Faculty (faculty_id, address, office_number) Advisor (faculty_id, student_id) Registered (student_id, course_id) Teacher (faculty_id, course_id) Grades (student_id, course_id, date, grade) - Students currently registered in the university - University faculty - The names of students and their advisors. - Specifies courses each student is currently registered in. - Specifies which faculty currently teach which courses. - Specifies the course grade for a student, and when they received that grade. a) What would be a candidate key for the advisor entity set? b) Would faculty_id, office_number be a candidate key for the faculty entity set?
Problem #3 (continued) Student (student_id, city, street, major) Faculty (faculty_id, address, office_number) Advisor (faculty_id, student_id) Registered (student_id, course_id) Teacher (faculty_id, course_id) Grades (student_id, course_id, date, grade) - Students currently registered in the university - University faculty - The names of students and their advisors. - Specifies courses each student is currently registered in. - Specifies which faculty currently teach which courses. - Specifies the course grade for a student, and when they received that grade. c) What would be a candidate key for the grades entity set? d) List all of the candidate keys for the student entity set. e) List all of the super keys for the faculty entity set
Problem # 4 (5 pts) Refer to the Database Schema #1 Provide the SQL statements to drop and create the Customer Schema. Problem #5 (10 pts) a) Under what circumstances would one consider using a file based system instead of a Database Management System (DBMS)? b) Under what circumstances would one consider using a DBMS instead of a file based system? Problem # 6 (15 pts) Draw a 3 tier top level architecture for an automated banking teller machine. Explain the events that must occur for the withdrawal of cash from an account. Should the architecture support asynchronous or synchronous communications?
Problem # 7 (10 pts) The Entity Relationship Diagram shows that a person owns some number of cars and each vehicle is insured by an Insurance Company. The problem is that an Insurance policy may insure more than one car, which makes the Insurance Schema a weak entity. a) Redesign the Database Schema using only binary relationships and no entity schema is a weak. b) Create the Relational Tables for your new design. Last Name First Name SS# Vehicle ID Type Make Person Has Vehicle Birth Date Age Gender Year Doors Color # of Accidents Expiration Date Insurance Cost per Accident Cost Policy Number
Problem # 8 (5 pts) Employee Department ( Employee-Name, SS, Birth-Date, Address, Dept-Number, Dept-Name, Dept-Mgr-SS) Functional Dependencies: FD1 = SS Employee-Name, Birth-Date, Address, Dept-Number FD2 = Dept-Number Dept-Name, Dept-Mgr-SS Is this table in 3 rd Normal Form? Convert the Relational Table into 3 rd Normal Form if your answer is No. Problem # 9 (5 pts) Employee Project ( SS, Project-Number, Employee-Name, Hours, Project-Name, Project-Location) Functional Dependencies: FD1 = SS Employee-Name FD2 = SS, Project-Number Hours FD2 = Project-Number Project-Name, Project Location Convert the Relational Table into 2 rd Normal Form.
Problem # 10 (5 pts) Interest ( SS, Last-Name, First-Name, Hobbies) Is this schema in the 1 st Normal Form, 2 nd Normal Form, 3 rd Normal Form, 4 th Normal Form, or all Normal Forms? Please explain your answer.
Database Systems CSE 5260 Fall 2005
Database Schema #1 Branch (Branch_Name, Branch_City, Assets) Customer (Customer_Name, SS#, Street, City, State, Zip_Code) Account (Account_Number, Branch_Name, Balance) Loan (Loan_Number, Branch_Name, Amount) Depositor (SS#, Account_Number) Borrower (SS#, Loan_Number)
Problem #1 (15 pts) Refer to the Database Schema #1. a) SQL - Find the names of all branches in the loan relations. Remove duplicate branch names. b) SQL Find all customers who have both a loan and an account at the bank. c) SQL Find the customer names and their loan numbers for all customers having a loan at some branch. Problem # 2 (5 pts) Refer to the Database Schema #1 Provide the SQL statements to drop and create the Customer Schema.
Problem #3 (15 pts) Consider the following relational schemes for storing information associated with a hospital. Patient (SS#, name, policy#) Visit (SS#, date-admitted, time-admitted) Doctor (DrSS#, name, specialty) Log (SS#, DrSS#, test_type, date, result) Provide a relational algebra expression for each of the following. a) A list of the social security numbers for those patients who had a test for asthma on the same date that they were admitted. b) A list of the social security numbers or those patients who visited (admitted) the hospital on 01/01/05. c) A list of the social security numbers of those patients who have each had a test for asthma and a test for anemia, but never had a test for bronchitis.
Problem #4 (15 pts) a) Define first normal form (1NF). b) Define second normal form (2NF). c) Define third normal form (3NF). Problem #5 (10 pts) a) Under what circumstances would one consider using a file based system instead of a Database Management System (DBMS)? b) Under what circumstances would one consider using a DBMS instead of a file based system? Problem # 6 (15 pts) Draw a 3 tier top level architecture for an automated banking teller machine. Explain the events that must occur for the withdrawal of cash from an account. Should the architecture support asynchronous or synchronous communications?
Problem # 7 (10 pts) The Entity Relationship Diagram shows that a person owns some number of cars and each vehicle is insured by an Insurance Company. The problem is that an Insurance policy may insure more than one car, which makes the Insurance Schema a weak entity. a) Redesign the Database Schema using only binary relationships and no entity schema is a weak. b) Create the Relational Tables for your new design. Last Name First Name SS# Vehicle ID Type Make Person Has Vehicle Birth Date Age Gender Year Doors Color # of Accidents Expiration Date Insurance Cost per Accident Cost Policy Number
Problem # 8 (5 pts) Employee Department ( Employee-Name, SS, Birth-Date, Address, Dept-Number, Dept-Name, Dept-Mgr-SS) Functional Dependencies: FD1 = SS Employee-Name, Birth-Date, Address, Dept-Number FD2 = Dept-Number Dept-Name, Dept-Mgr-SS Is this table in 3 rd Normal Form? Convert the Relational Table into 3 rd Normal Form if your answer is No. Problem # 9 (5 pts) Employee Project ( SS, Project-Number, Employee-Name, Hours, Project-Name, Project-Location) Functional Dependencies: FD1 = SS Employee-Name FD2 = SS, Project-Number Hours FD2 = Project-Number Project-Name, Project Location Convert the Relational Table into 2 rd Normal Form.
Problem # 10 (5 pts) Interest ( SS, Last-Name, First-Name, Hobbies) Is this schema in the 1 st Normal Form, 2 nd Normal Form, 3 rd Normal Form, 4 th Normal Form, or all Normal Forms? Please explain your answer.
Database Systems CSE 5260 Spring 2006
Database Schema #1 Student (SS#, Student_Name, street, city, State, ZIP) Offering (department, number, section, time, location, population) -- Courses currently offered for CSE 5260 department is CSE and number is 5260. Titles (department, number, title) Enrollment (student-name, department, number, section)
Problem #1 (20 pts) Refer to Database Schema #1. Give a SQL expression for each of the following. a) Provide the department, number, section, and title for every course section that has more than 25 students enrolled; i.e., the population > 25. b) Provide a list of cities that have at least two student residents. c) Provide a list of students that live in Orlando and take the course Database. Sort the list in alphabetical order. d) Provide a list of student names, department, number, title and population for all courses offered. Sort the list by the course titles.
Problem #2 (25 pts) a) Define first normal form (1NF). b) Define second normal form (2NF). c) Define third normal form (3NF). d) Provide a formal definition for Functional Dependency Preservation. e) Define what is meant by a non-procedural query language? Give an example of a procedural and non-procedural query language. Problem #3 (10 pts) Under what circumstances would one consider using a file based system instead of a Database Management System (DBMS)?
Problem # 4 (15 pts) Create the Relational Database Tables for the Entity Relationship Diagram shown below. Underline the primary keys. The schema shows that a person can own and drive multiple vehicles and insure the vehicles under one insurance policy. The attribute # of Accidents, Cost, and Expiration Date applies to each car, which makes the relation schema Insurance a weak entity. Last Name First Name SS# Vehicle ID Type Make Person drives Vehicle Birth Date Age Gender Year Color Expiration Date Insurance # of Accidents Cost Policy Number
Problem # 5 (15 pts) Employee ( SS#, Project-Number, Last-Name, First-Name, Street, Zip, Project-Name, Project-Location) Address (Zip, City, County, State) Convert the database schema into 3rd Normal Form. Problem # 6 (15 pts) a) Provide an example of a loss-less join decomposition. Ensure you provide an adequate explanation for your example. b) Suppose a relation schema R is decomposed into {R1, R2}. What conditions must hold true to ensure the decomposition is loss-less. c) Suppose a relation schema R with functional dependencies F = {A B, B C, C D} is decomposed into {R1, R2}. The functional dependencies for R1 is F1={A B} and the functional dependency for R2 is F2 = {C D}. Is the decomposition R = {R1, R2} a loss-less join decomposition, Yes or No? Provide an explanation for your answer.
Database Systems CSE 5260 Fall 2006
Database Schema #1 Student (SS#, Student_Name, Street, City, State, ZIP) Offering (Department, Number, Section, Time, Location, Population) -- Courses currently offered for CSE 5260 department is CSE and number is 5260. Titles (Department, Number, Title) Enrollment (Student-name, Department, Number, Section)
Problem #1 (15 pts) Refer to Database Schema #1. Provide a SQL expression for each of the following. a) Provide the department, number, section, and title for every course section that has more than 25 students enrolled; i.e., the population > 25. c) Provide a list of student names that take the course Database. Sort the list in alphabetical order. d) Provide a list of student names and their Social Security Numbers that take the course Database in Section 3N. Problem #2 (25 pts) a) Define first normal form (1NF). b) Define second normal form (2NF). c) Define third normal form (3NF). d) Provide a formal definition for Functional Dependency Preservation. e) Define what is meant by a non-procedural query language? Give an example of a procedural and non-procedural query language.
Problem #3 (15 pts) Consider the following relational schemes for storing information associated with a hospital. Patient (SS#, name, policy#) Visit (SS#, date-admitted, time-admitted) Doctor (DrSS#, name, specialty) Log (SS#, DrSS#, test_type, date, result) Provide a relational algebra expression for each of the following. a) A list of the social security numbers for those patients who had a test for asthma on the same date that they were admitted. b) A list of the social security numbers for those patients who visited (admitted) the hospital on 01/01/05. c) A list of social security numbers for those patients that where admitted to the hospital on 01/01/05 and did not have an insurance policy.
Problem # 4 (15 pts) Create the Relational Database Tables for the Entity Relationship Diagram shown below. Underline the primary keys. The schema shows that a person can own and drive multiple vehicles and insure the vehicles under one insurance policy. The attribute # of Accidents, Cost, and Expiration Date applies to each car, which makes the relation schema Insurance a weak entity. Last Name First Name SS# Vehicle ID Type Make Person drives Vehicle Birth Date Age Gender Year Color Expiration Date Insurance # of Accidents Cost Policy Number
Problem # 5 (15 pts) Employee ( SS#, Project-Number, Last-Name, First-Name, Street, Zip, Project-Name, Project-Location) Address (Zip, City, County, State) Convert the database schema into 3rd Normal Form. Problem # 6 (15 pts) a) Provide an example of a loss-less join decomposition. Ensure you provide an adequate explanation for your example. b) Suppose a relation schema R is decomposed into {R1, R2}. What conditions must hold true to ensure the decomposition is loss-less. c) Suppose a relation schema R with functional dependencies F = {A B, B C, C D} is decomposed into {R1, R2}. The functional dependencies for R1 is F1={A B} and the functional dependency for R2 is F2 = {C D}. Is the decomposition R = {R1, R2} a loss-less join decomposition, Yes or No? Provide an explanation for your answer.
Database Systems CSE 5260 Fall 2008
Problem #1 a) Define first normal form (1NF). b) Define second normal form (2NF). c) Define third normal form (3NF). d) Define BCNF Problem #2 a) Provide a formal definition for Functional Dependency Preservation. b) Provide an example of a loss-less join decomposition. Ensure you provide an adequate explanation for your example. Problem #3 Define what is meant by a non-procedural query language? Give an example of a procedural and non-procedural query language. Problem #4 Under what circumstances would one consider using a file based system instead of a Database Management System (DBMS)?
Problem # 5 Create the Relational Database Tables for the Entity Relationship Diagram shown below. Underline the primary keys. The schema shows that a person can own and drive multiple vehicles and insure the vehicles under one insurance policy. The attribute # of Accidents, Cost, and Expiration Date applies to each car, which makes the relation schema Insurance a weak entity. Last Name First Name SS# Vehicle ID Type Make Person drives Vehicle Birth Date Age Gender Year Color Expiration Date Insurance # of Accidents Cost Policy Number