CS40 Exam #2 November 14, 2001

Similar documents
CS40 Exam #2 November 13, 2002

CS40 Exam #1 October 17, 2001

CS450 - Database Concepts Fall 2015

Relational Model, Key Constraints

CS275 Intro to Databases

Chapter 3: Introduction to SQL. Chapter 3: Introduction to SQL

Chapter 3: Introduction to SQL

NJIT Department of Computer Science PhD Qualifying Exam on CS 631: DATA MANAGEMENT SYSTEMS DESIGN. Summer 2012

Intermediate SQL ( )

Chapter 4. Basic SQL. SQL Data Definition and Data Types. Basic SQL. SQL language SQL. Terminology: CREATE statement

Referential integrity

QQ Group

CS 582 Database Management Systems II

CS348: INTRODUCTION TO DATABASE MANAGEMENT (Winter, 2011) FINAL EXAMINATION

Chapter 3: Introduction to SQL


From E/R Diagrams to Relations

The SQL data-definition language (DDL) allows defining :

CSE 530 Midterm Exam

EGCI 321: Database Systems. Dr. Tanasanee Phienthrakul

Databases CSCI 201 Principles of Software Development

CS425 Fall 2016 Boris Glavic Chapter 2: Intro to Relational Model

Database Management Systems,

The DBMS accepts requests for data from the application program and instructs the operating system to transfer the appropriate data.

FIT 100 More Microsoft Access and Relational Databases Creating Views with SQL

Accessing databases in Java using JDBC

In this Lecture. More SQL Data Definition. Deleting Tables. Creating Tables. ALTERing Columns. Changing Tables. More SQL

The Relational Model Constraints and SQL DDL

SQL: Data Definition Language. csc343, Introduction to Databases Diane Horton Fall 2017

CS145 Final Examination

CSE 344 Midterm. Wednesday, February 19, 2014, 14:30-15:20. Question Points Score Total: 100

SYSTEM CODE COURSE NAME DESCRIPTION SEM

ER to Relational Model. Professor Jessica Lin

Debapriyo Majumdar DBMS Fall 2016 Indian Statistical Institute Kolkata

Midterm Exam #2 (Version A) CS 122A Winter 2017

1 (10) 2 (8) 3 (12) 4 (14) 5 (6) Total (50)

CS2102, D15 Exam 1. Name:

EMBEDDED SQL. SE 3DB3 Fall 2016 MICHAEL LIUT DEPARTMENT OF COMPUTING AND SOFTWARE MCMASTER UNIVERSITY

Database Management System Dr. S. Srinath Department of Computer Science & Engineering Indian Institute of Technology, Madras Lecture No.

Midterm Exam #2 (Version B) CS 122A Spring 2018

Chapter 1 SQL and Data

MET CS 669 Database Design and Implementation for Business Term Project: Online DVD Rental Business

Debapriyo Majumdar DBMS Fall 2016 Indian Statistical Institute Kolkata

Handout 6 CS-605 Spring 18 Page 1 of 7. Handout 6. Physical Database Modeling

SQL Functions (Single-Row, Aggregate)

CGS 3066: Spring 2017 SQL Reference

CS425 Fall 2017 Boris Glavic Chapter 4: Introduction to SQL

Where Are We? Next Few Lectures. Integrity Constraints Motivation. Constraints in E/R Diagrams. Keys in E/R Diagrams

Information Systems Engineering. SQL Structured Query Language DDL Data Definition (sub)language

Implementing Table Operations Using Structured Query Language (SQL) Using Multiple Operations. SQL: Structured Query Language

Constraints. Local and Global Constraints Triggers

CIS 632_Pre-Requisite Quiz Introductory Project Dr. H. Assadipour

Who, where, when. Database Management Systems (LIX022B05) Literature. Evaluation. Lab Sessions. About this course. After this course...

Embedded SQL. csc343, Introduction to Databases Renée J. Miller and Fatemeh Nargesian and Sina Meraji Winter 2018

Databases. Jörg Endrullis. VU University Amsterdam

Databases II: Microsoft Access

Chapter 4: Intermediate SQL

CSCB20 Week 2. Introduction to Database and Web Application Programming. Anna Bretscher Winter 2017

G64DBS Database Systems. Lecture 7 SQL SELECT. The Data Dictionary. Data Dictionaries. Different Sections of SQL (DDL) Different Sections of SQL (DCL)

Database Systems: An Application-Oriented Approach (Complete Version) Practice Problems and Solutions for Students

Answer Key for Exam II Computer Science 420 Dr. St. John Lehman College City University of New York 18 April 2002

Birkbeck. (University of London) BSc/FD EXAMINATION. Department of Computer Science and Information Systems. Database Management (COIY028H6)

Midterm Exam #2 (Version B) CS 122A Spring 2018

CSE344 Final Exam Winter 2017

CSE 344 Final Examination

Name: Database Systems ( 資料庫系統 ) Midterm exam, November 15, 2006

CSC 261/461 Database Systems Lecture 6. Fall 2017

CS 4604: Introduc0on to Database Management Systems. B. Aditya Prakash Lecture #4: SQL---Part 2

GlobAl EDITION. Database Concepts SEVENTH EDITION. David M. Kroenke David J. Auer

Simple SQL. Peter Y. Wu. Dept of Computer and Information Systems Robert Morris University

Midterm Exam #2 (Version C) CS 122A Spring 2018

CS127 Homework #3. Due: October 11th, :59 P.M. Consider the following set of functional dependencies, F, for the schema R(A, B, C, D, E)

Examination paper for TDT4145 Data Modelling and Database Systems

Outline. Database Management Systems (DBMS) Database Management and Organization. IT420: Database Management and Organization

Relational Algebra. Relational Query Languages

Triggers- View-Sequence

Chapter 4: Intermediate SQL

CS2300: File Structures and Introduction to Database Systems

Lab # 9. Java to Database Connection

Working with Databases and Java

The Relational Model. Week 2

Full file at

Homework #4 1. Suppose that each of the following Update operations is applied directly to the database state shown in Figure 5.6.

3 February 2011 CSE-3421M Test #1 p. 1 of 14. CSE-3421M Test #1. Design

CSE 544 Principles of Database Management Systems

SQL DATA DEFINITION LANGUAGE

Chapter Five Physical Database Design

CS W Introduction to Databases Spring Computer Science Department Columbia University

1- a> [5pts] Create the new table by writing and executing a full SQL DDL statement based on the following schema:

CS 200. Lecture 06. Database Introduction. Database Introduction. CS 200 Winter 2018

PLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science

SQL: A COMMERCIAL DATABASE LANGUAGE. Data Change Statements,

Databases 1. Defining Tables, Constraints

Data! CS 133: Databases. Goals for Today. So, what is a database? What is a database anyway? From the textbook:

Overview. Database Application Development. SQL in Application Code. SQL in Application Code (cont.)

Database Application Development

Database Application Development

CS 474, Spring 2016 Midterm Exam #2

Chapter 4: Intermediate SQL

This lecture. Basic Syntax

Transcription:

CS40 Exam #2 November 14, 2001 Name: Except where explicitly noted, all of the questions on this exam refer to the database defined by the relational schemas given on the last page of this exam. 1. Suppose that the Student Records database is to be augmented by a table called Testbank, which will contain exam questions. Assume that each question must relate to one or more courses. The schema is given on the last page. a. Write an SQL statement that will create this table, using the most appropriate data types. (You do not have to set any constraints other than those required by the problem statement.) [8 points] b. Write an SQL statement to insert the question: What is your favorite color? for CS40, with the answer Blue. No yell-oooooaaaah!. [6 points] c. Without making any assumptions about existing database contents, explain a possible anomaly that might occur when this insertion is made. [6 points]

2. a. You have cleverly gained access to the airtight Furman grades database. (No easy task!) Your student number is 19, your roommate s is 34 and your girl/boyfriend s is 41. Write an SQL statement to change all grades to A for all classes for the three of you. (For full credit, you must not use stunum= three times.) [7 points] b. Write a SQL statement to delete all of the records in the Course table for CS40. [7 points] c. What would happen as a result of the statement given in part (b) [6 points] if Sections was defined using the clause ON DELETE CASCADE? if Testbank was defined using the clause ON DELETE SET NULL? if Sections or Testbank was defined using the clause ON DELETE RESTRICT? 3. Write SQL queries for the following: [10 points each] a. List (in alphabetical order by name) the course number and student name for all courses taken by CS majors. b. List the names of all students who have received an A in a course taught by Dr. Gabbert. Don t repeat any names.

4. Write SQL queries for the following: [10 points each] a. List the student number, student name and count of grades for each student. The column header for the grade count should be NumGrades. b. List the student numbers and student names of all students who have received at least one grade, but have never failed a class. 5. a. List and briefly explain the steps that must be taken by a Java program to run a SELECT statement on a database using JDBC. You should add at least four steps to the list below. Your answers should demonstrate that you understand what you re talking about, not just that you can regurgitate something you read. [12 points] First step Create a null (empty) Connection object from the java.sql package Last step Loop through the ResultSet object, printing the attributes for each row, formatted appropriately. b. Consider the PINonlyGrades.php and JDBCTest.java applications that we studied in the last two labs. Suppose we wanted to modify them to run a different query against data in a different DBMS. For which application would it be easier to do this? Justify your answer with specific details. [8 points]

6. Short Answer: [5 points each] a. What is the purpose of the getmetadata method of the ResultSet class? b. In the following SQL statement: SELECT title FROM Movie WHERE genre= comedy ; which relational algebra operation is used to implement the underlined part? c. Which of the database management systems that we have studied support QBE as a predominant technique? d. Suppose you have executed the following SQL command in Oracle: create view StudentGrades as select st.stunum, st.stuname, g.secid, g.grade from student st, grades g where st.stunum = g.stunum; Give a short SQL statement that would produce the student number, student name, section ID and grade for every grade earned by student #19.

Relational Schemas for Course and Grade Database Table Attribute Data Type Keys and custom rules Student stunum number(4) primary key specify a value range: stunum between 8 and 20 stuname varchar2(8) class number(1) custom rule: class in ( 1, 2, 3, 4 ) major varchar2(4) Course cournum varchar2( 6) primary key courname varchar2( 30) credithr number( 1) custom rule: credithr in ( 2, 4 ) dept varchar2( 4) Prereq cournum varchar2( 6) primary key and foreign key prereqnm varchar2( 6) primary key and foreign key Cournum and prereqnm together form the primary key. Separately they are foreign keys. Sections secid number(4) primary key cournum varchar2 (6) foreign key semester varchar2(6) acadyear number(4) custom rule: year between 1997 and 2001 instr varchar2(10) Grades stunum number( 4) part of primary key and a foreign key secid number( 4) part of primary key and a foreign key Stunum and secid together form the primary key. Separately they are foreign keys. grade char 1 custom rule : grade in ( A, B, C, D, F ) Testbank questionid?? primary key, automatically generated cournum?? foreign key question?? could potentially be very long answer?? could potentially be very long