CS40 Exam #2 November 14, 2001

Size: px
Start display at page:

Download "CS40 Exam #2 November 14, 2001"

Transcription

1 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 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.

3 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]

4 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.

5 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

CS40 Exam #2 November 13, 2002

CS40 Exam #2 November 13, 2002 CS40 Exam #2 November 13, 2002 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. For

More information

CS40 Exam #1 October 17, 2001

CS40 Exam #1 October 17, 2001 CS40 Exam #1 October 17, 2001 Name: 1. Short answer [5 points each]: a. Consider an ER diagram giving a conceptual schema for an Amazon.com shopping basket. A basket can contain any number of items, each

More information

CS450 - Database Concepts Fall 2015

CS450 - Database Concepts Fall 2015 CS450 - Database Concepts Fall 2015 Instructor: Dr. Jessica Lin Project Assignment General. Your project is to design and implement a database for an online movie rental company like Netflix (for this

More information

Relational Model, Key Constraints

Relational Model, Key Constraints Relational Model, Key Constraints PDBM 6.1 Dr. Chris Mayfield Department of Computer Science James Madison University Jan 23, 2019 What is a data model? Notation for describing data or information Structure

More information

CS275 Intro to Databases

CS275 Intro to Databases CS275 Intro to Databases The Relational Data Model Chap. 3 How Is Data Retrieved and Manipulated? Queries Data manipulation language (DML) Retrieval Add Delete Update An Example UNIVERSITY database Information

More information

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

Chapter 3: Introduction to SQL. Chapter 3: Introduction to SQL Chapter 3: Introduction to SQL Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 3: Introduction to SQL Overview of The SQL Query Language Data Definition Basic Query

More information

Chapter 3: Introduction to SQL

Chapter 3: Introduction to SQL Chapter 3: Introduction to SQL Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 3: Introduction to SQL Overview of the SQL Query Language Data Definition Basic Query

More information

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

NJIT Department of Computer Science PhD Qualifying Exam on CS 631: DATA MANAGEMENT SYSTEMS DESIGN. Summer 2012 JIT Department of Computer Science PhD Qualifying Exam on CS 63: DATA MAAGEMET SYSTEMS DESIG Summer 202 o book or other document is allowed. Duration of the exam: 2.5 hours. The total number of points

More information

Intermediate SQL ( )

Intermediate SQL ( ) CSL 451 Introduction to Database Systems Intermediate SQL (4.1-4.4) Department of Computer Science and Engineering Indian Institute of Technology Ropar Narayanan (CK) Chatapuram Krishnan! Summary Join

More information

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

Chapter 4. Basic SQL. SQL Data Definition and Data Types. Basic SQL. SQL language SQL. Terminology: CREATE statement Chapter 4 Basic SQL Basic SQL SQL language Considered one of the major reasons for the commercial success of relational databases SQL Structured Query Language Statements for data definitions, queries,

More information

Referential integrity

Referential integrity Referential integrity Another function of the DBMS is to ensure referential integrity. This refers to the concept that a foreign key in a relation must have a corresponding entry in the table to which

More information

QQ Group

QQ Group QQ Group: 617230453 1 Extended Relational-Algebra-Operations Generalized Projection Aggregate Functions Outer Join 2 Generalized Projection Extends the projection operation by allowing arithmetic functions

More information

CS 582 Database Management Systems II

CS 582 Database Management Systems II Review of SQL Basics SQL overview Several parts Data-definition language (DDL): insert, delete, modify schemas Data-manipulation language (DML): insert, delete, modify tuples Integrity View definition

More information

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

CS348: INTRODUCTION TO DATABASE MANAGEMENT (Winter, 2011) FINAL EXAMINATION CS348: INTRODUCTION TO DATABASE MANAGEMENT (Winter, 2011) FINAL EXAMINATION INSTRUCTOR: Grant Weddell TIME: 150 minutes WRITE YOUR NAME AND ID HERE: NOTE 1: This is a closed book examination. For example,

More information

Chapter 3: Introduction to SQL

Chapter 3: Introduction to SQL Chapter 3: Introduction to SQL Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 3: Introduction to SQL Overview of the SQL Query Language Data Definition Basic Query

More information

CS6302 DBMS 2MARK & 16 MARK UNIT II SQL & QUERY ORTIMIZATION 1. Define Aggregate Functions in SQL? Aggregate function are functions that take a collection of values as input and return a single value.

More information

From E/R Diagrams to Relations

From E/R Diagrams to Relations From E/R Diagrams to Relations Entity set relation Attributes attributes Relationships relations whose attributes are only: The keys of the connected entity sets Attributes of the relationship itself 1

More information

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

The SQL data-definition language (DDL) allows defining : Introduction to SQL Introduction to SQL Overview of the SQL Query Language Data Definition Basic Query Structure Additional Basic Operations Set Operations Null Values Aggregate Functions Nested Subqueries

More information

CSE 530 Midterm Exam

CSE 530 Midterm Exam CSE 530 Midterm Exam Name: (Print CLEARLY) Question Points Possible Points Earned 1 25 2 10 3 20 4 20 5 15 Total 90 1 Question 1 Heap Files Suppose we want to create a heap file with a page size of 512

More information

EGCI 321: Database Systems. Dr. Tanasanee Phienthrakul

EGCI 321: Database Systems. Dr. Tanasanee Phienthrakul 1 EGCI 321: Database Systems Dr. Tanasanee Phienthrakul 2 Chapter 10 Data Definition Language (DDL) 3 Basic SQL SQL language Considered one of the major reasons for the commercial success of relational

More information

Databases CSCI 201 Principles of Software Development

Databases CSCI 201 Principles of Software Development Databases CSCI 201 Principles of Software Development Jeffrey Miller, Ph.D. jeffrey.miller@usc.edu Outline Databases SQL Try It! USC CSCI 201L Databases Database systems store data and provide a means

More information

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

CS425 Fall 2016 Boris Glavic Chapter 2: Intro to Relational Model CS425 Fall 2016 Boris Glavic Chapter 2: Intro to Relational Model Modifies from: Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Textbook: Chapter 2 2.2 Example of a Relation

More information

Database Management Systems,

Database Management Systems, Database Management Systems SQL Query Language (1) 1 Topics Introduction SQL History Domain Definition Elementary Domains User-defined Domains Creating Tables Constraint Definition INSERT Query SELECT

More information

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

The DBMS accepts requests for data from the application program and instructs the operating system to transfer the appropriate data. Managing Data Data storage tool must provide the following features: Data definition (data structuring) Data entry (to add new data) Data editing (to change existing data) Querying (a means of extracting

More information

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

FIT 100 More Microsoft Access and Relational Databases Creating Views with SQL FIT 100 More Microsoft Access and Relational Databases Creating Views with SQL Creating Views with SQL... 1 1. Query Construction in SQL View:... 2 2. Use the QBE:... 5 3. Practice (use the QBE):... 6

More information

Accessing databases in Java using JDBC

Accessing databases in Java using JDBC Accessing databases in Java using JDBC Introduction JDBC is an API for Java that allows working with relational databases. JDBC offers the possibility to use SQL statements for DDL and DML statements.

More information

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

In this Lecture. More SQL Data Definition. Deleting Tables. Creating Tables. ALTERing Columns. Changing Tables. More SQL In this Lecture Database Systems Lecture 6 Natasha Alechina More SQL DROP TABLE ALTER TABLE INSERT, UPDATE, and DELETE Data dictionary Sequences For more information Connolly and Begg chapters 5 and 6

More information

The Relational Model Constraints and SQL DDL

The Relational Model Constraints and SQL DDL The Relational Model Constraints and SQL DDL Week 2-3 Weeks 2-3 MIE253-Consens 1 Schedule Week Date Lecture Topic 1 Jan 9 Introduction to Data Management 2 Jan 16 The Relational Model 3 Jan. 23 Constraints

More information

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

SQL: Data Definition Language. csc343, Introduction to Databases Diane Horton Fall 2017 SQL: Data Definition Language csc343, Introduction to Databases Diane Horton Fall 2017 Types Table attributes have types When creating a table, you must define the type of each attribute. Analogous to

More information

CS145 Final Examination

CS145 Final Examination CS145 Final Examination Spring 2003, Prof. Widom ffl Please read all instructions (including these) carefully. ffl There are 11 problems on the exam, with a varying number of points for each problem and

More information

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

CSE 344 Midterm. Wednesday, February 19, 2014, 14:30-15:20. Question Points Score Total: 100 CSE 344 Midterm Wednesday, February 19, 2014, 14:30-15:20 Name: Question Points Score 1 30 2 50 3 12 4 8 Total: 100 This exam is open book and open notes but NO laptops or other portable devices. You have

More information

SYSTEM CODE COURSE NAME DESCRIPTION SEM

SYSTEM CODE COURSE NAME DESCRIPTION SEM Course: CS691- Database Management System Lab PROGRAMME: COMPUTER SCIENCE & ENGINEERING DEGREE:B. TECH COURSE: Database Management System Lab SEMESTER: VI CREDITS: 2 COURSECODE: CS691 COURSE TYPE: Practical

More information

ER to Relational Model. Professor Jessica Lin

ER to Relational Model. Professor Jessica Lin ER to Relational Model Professor Jessica Lin 1 Reduction to Relation Schemas Entity sets and relationship sets can be expressed uniformly as relation schemas that represent the contents of the database.

More information

Debapriyo Majumdar DBMS Fall 2016 Indian Statistical Institute Kolkata

Debapriyo Majumdar DBMS Fall 2016 Indian Statistical Institute Kolkata SQL 4 Debapriyo Majumdar DBMS Fall 2016 Indian Statistical Institute Kolkata Slides re-used, with minor modification, from Silberschatz, Korth and Sudarshan www.db-book.com Outline Join Expressions Views

More information

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

Midterm Exam #2 (Version A) CS 122A Winter 2017 NAME: SEAT NO.: STUDENT ID: Midterm Exam #2 (Version A) CS 122A Winter 2017 Max. Points: 100 (Please read the instructions carefully) Instructions: - The total time for the exam is 50 minutes; be sure

More information

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

1 (10) 2 (8) 3 (12) 4 (14) 5 (6) Total (50) Student number: Signature: UNIVERSITY OF VICTORIA Faculty of Engineering Department of Computer Science CSC 370 (Database Systems) Instructor: Daniel M. German Midterm Oct 21, 2004 Duration: 60 minutes

More information

CS2102, D15 Exam 1. Name:

CS2102, D15 Exam 1. Name: CS2102, D15 Exam 1 Name: You have 50 minutes to complete the problems on the following pages. There should be sufficient space provided for your answers. If a problem asks you to create a class hierarchy,

More information

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

EMBEDDED SQL. SE 3DB3 Fall 2016 MICHAEL LIUT DEPARTMENT OF COMPUTING AND SOFTWARE MCMASTER UNIVERSITY EMBEDDED SQL MICHAEL LIUT (LIUTM@MCMASTER.CA) DEPARTMENT OF COMPUTING AND SOFTWARE MCMASTER UNIVERSITY SE 3DB3 Fall 2016 (Slides adapted from Dr. Fei Chiang, Diane Horton, examples from J. Ullman, J. Widom)

More information

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

Database Management System Dr. S. Srinath Department of Computer Science & Engineering Indian Institute of Technology, Madras Lecture No. Database Management System Dr. S. Srinath Department of Computer Science & Engineering Indian Institute of Technology, Madras Lecture No. # 5 Structured Query Language Hello and greetings. In the ongoing

More information

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

Midterm Exam #2 (Version B) CS 122A Spring 2018 NAME: SEAT NO.: STUDENT ID: Midterm Exam #2 (Version B) CS 122A Spring 2018 Max. Points: 100 (Please read the instructions carefully) Instructions: - The total time for the exam is 50 minutes; be sure

More information

Chapter 1 SQL and Data

Chapter 1 SQL and Data Chapter 1 SQL and Data What is SQL? Structured Query Language An industry-standard language used to access & manipulate data stored in a relational database E. F. Codd, 1970 s IBM 2 What is Oracle? A relational

More information

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

MET CS 669 Database Design and Implementation for Business Term Project: Online DVD Rental Business MET CS 669 Database Design and Implementation for Business Term Project: Online DVD Rental Business Objective Create an initial design for the database schema for an online DVD rental business that is

More information

Debapriyo Majumdar DBMS Fall 2016 Indian Statistical Institute Kolkata

Debapriyo Majumdar DBMS Fall 2016 Indian Statistical Institute Kolkata SQL 3 Debapriyo Majumdar DBMS Fall 2016 Indian Statistical Institute Kolkata Slides re-used, with minor modification, from Silberschatz, Korth and Sudarshan www.db-book.com Outline Join Expressions Views

More information

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

Handout 6 CS-605 Spring 18 Page 1 of 7. Handout 6. Physical Database Modeling Handout 6 CS-605 Spring 18 Page 1 of 7 Handout 6 Physical Database Modeling Purpose- translate the logical description of data into the technical specifications for storing and retrieving data Goal - create

More information

SQL Functions (Single-Row, Aggregate)

SQL Functions (Single-Row, Aggregate) Islamic University Of Gaza Faculty of Engineering Computer Engineering Department Database Lab (ECOM 4113) Lab 4 SQL Functions (Single-Row, Aggregate) Eng. Ibraheem Lubbad Part one: Single-Row Functions:

More information

CGS 3066: Spring 2017 SQL Reference

CGS 3066: Spring 2017 SQL Reference CGS 3066: Spring 2017 SQL Reference Can also be used as a study guide. Only covers topics discussed in class. This is by no means a complete guide to SQL. Database accounts are being set up for all students

More information

CS425 Fall 2017 Boris Glavic Chapter 4: Introduction to SQL

CS425 Fall 2017 Boris Glavic Chapter 4: Introduction to SQL CS425 Fall 2017 Boris Glavic Chapter 4: Introduction to SQL Modified from: Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 4: Introduction to SQL Overview of the

More information

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

Where Are We? Next Few Lectures. Integrity Constraints Motivation. Constraints in E/R Diagrams. Keys in E/R Diagrams Where Are We? Introduction to Data Management CSE 344 Lecture 15: Constraints We know quite a bit about using a DBMS Start with real-world problem, design ER diagram From ER diagram to relations -> conceptual

More information

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

Information Systems Engineering. SQL Structured Query Language DDL Data Definition (sub)language Information Systems Engineering SQL Structured Query Language DDL Data Definition (sub)language 1 SQL Standard Language for the Definition, Querying and Manipulation of Relational Databases on DBMSs Its

More information

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

Implementing Table Operations Using Structured Query Language (SQL) Using Multiple Operations. SQL: Structured Query Language Implementing Table Operations Using Structured Query Language (SQL) Using Multiple Operations Show Only certain columns and rows from the join of Table A with Table B The implementation of table operations

More information

Constraints. Local and Global Constraints Triggers

Constraints. Local and Global Constraints Triggers Constraints Foreign Keys Local and Global Constraints Triggers 1 Constraints and Triggers A constraint is a relationship among data elements that the DBMS is required to enforce. Example: key constraints.

More information

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

CIS 632_Pre-Requisite Quiz Introductory Project Dr. H. Assadipour CIS 632_Pre-Requisite Quiz Introductory Project Dr. H. Assadipour 1. Table creation: CREATE TABLE Student_01 (sid number, sname varchar(20), address varchar(30), primary key (sid)); //Execute DESC Student_01;

More information

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

Who, where, when. Database Management Systems (LIX022B05) Literature. Evaluation. Lab Sessions. About this course. After this course... Who, where, when base Management Systems (LIX022B05) Instructor: Çağrı Çöltekin c.coltekin@rug.nl Information science/informatiekunde Fall 2012 Course bases (LIX022B05) 2012/13 Instructor Çağrı Çöltekin

More information

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

Embedded SQL. csc343, Introduction to Databases Renée J. Miller and Fatemeh Nargesian and Sina Meraji Winter 2018 Embedded SQL csc343, Introduction to Databases Renée J. Miller and Fatemeh Nargesian and Sina Meraji Winter 2018 Problems with using interactive SQL Standard SQL is not Turing-complete. E.g., Two profs

More information

Databases. Jörg Endrullis. VU University Amsterdam

Databases. Jörg Endrullis. VU University Amsterdam Databases Jörg Endrullis VU University Amsterdam The Relational Model Overview 1. Relational Model Concepts: Schema, State 2. Null Values 3. Constraints: General Remarks 4. Key Constraints 5. Foreign Key

More information

Databases II: Microsoft Access

Databases II: Microsoft Access Recapitulation Databases II: Microsoft Access CS111, 2016 A database is a collection of data that is systematically organized, so as to allow efficient addition, modification, removal and retrieval. A

More information

Chapter 4: Intermediate SQL

Chapter 4: Intermediate SQL Chapter 4: Intermediate SQL Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 4: Intermediate SQL Join Expressions Views Transactions Integrity Constraints SQL Data

More information

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

CSCB20 Week 2. Introduction to Database and Web Application Programming. Anna Bretscher Winter 2017 CSCB20 Week 2 Introduction to Database and Web Application Programming Anna Bretscher Winter 2017 This Week Quick Review of terminology Relational Model Continued Relational diagrams Relational operations

More information

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

G64DBS Database Systems. Lecture 7 SQL SELECT. The Data Dictionary. Data Dictionaries. Different Sections of SQL (DDL) Different Sections of SQL (DCL) G64DBS Database Systems Lecture 7 SQL SELECT Tim Brailsford Different Sections of SQL (DDL) The Data Definition Language (DDL): CREATE TABLE - creates a new database table ALTER TABLE - alters (changes)

More information

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

Database Systems: An Application-Oriented Approach (Complete Version) Practice Problems and Solutions for Students Database Systems: An Application-Oriented Approach (Complete Version) Practice Problems and Solutions for Students Michael Kifer, Arthur Bernstein, Philip M. Lewis 1 Contents Problems for Chapter 3: The

More information

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

Answer Key for Exam II Computer Science 420 Dr. St. John Lehman College City University of New York 18 April 2002 Answer Key for Exam II Computer Science 420 Dr. St. John Lehman College City University of New York 18 April 2002 1. True or False: (a) T Every set is a bag. (b) T SQL regards relations as bags of tuples,

More information

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

Birkbeck. (University of London) BSc/FD EXAMINATION. Department of Computer Science and Information Systems. Database Management (COIY028H6) Birkbeck (University of London) BSc/FD EXAMINATION Department of Computer Science and Information Systems Database Management (COIY028H6) CREDIT VALUE: 15 credits Date of examination: Monday 9th June 2014

More information

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

Midterm Exam #2 (Version B) CS 122A Spring 2018 NAME: SEAT NO.: STUDENT ID: Midterm Exam #2 (Version B) CS 122A Spring 2018 Max. Points: 100 (Please read the instructions carefully) Instructions: - The total time for the exam is 50 minutes; be sure

More information

CSE344 Final Exam Winter 2017

CSE344 Final Exam Winter 2017 CSE344 Final Exam Winter 2017 March 16, 2017 Please read all instructions (including these) carefully. This is a closed book exam. You are allowed two pages of note sheets that you can write on both sides.

More information

CSE 344 Final Examination

CSE 344 Final Examination CSE 344 Final Examination December 12, 2012, 8:30am - 10:20am Name: Question Points Score 1 30 2 20 3 30 4 20 Total: 100 This exam is open book and open notes but NO laptops or other portable devices.

More information

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

Name: Database Systems ( 資料庫系統 ) Midterm exam, November 15, 2006 1 of 8 pages Database Systems ( 資料庫系統 ) Midterm exam, November 15, 2006 Time: 10:00 ~ 12:20 Name: Student ID: I herewith state that I understand and will adhere to the following academic integrity: I will

More information

CSC 261/461 Database Systems Lecture 6. Fall 2017

CSC 261/461 Database Systems Lecture 6. Fall 2017 CSC 261/461 Database Systems Lecture 6 Fall 2017 Use of WITH The WITH clause allows a user to define a table that will only be used in a particular query (not available in all SQL implementations) Used

More information

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

CS 4604: Introduc0on to Database Management Systems. B. Aditya Prakash Lecture #4: SQL---Part 2 CS 4604: Introduc0on to Database Management Systems B. Aditya Prakash Lecture #4: SQL---Part 2 Overview - detailed - SQL DML other parts: views modifications joins DDL constraints Prakash 2016 VT CS 4604

More information

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

GlobAl EDITION. Database Concepts SEVENTH EDITION. David M. Kroenke David J. Auer GlobAl EDITION Database Concepts SEVENTH EDITION David M. Kroenke David J. Auer This page is intentionally left blank. Chapter 3 Structured Query Language 157 the comment. We will use similar comments

More information

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

Simple SQL. Peter Y. Wu. Dept of Computer and Information Systems Robert Morris University Simple SQL Peter Y. Dept of Computer and Information Systems Robert Morris University Simple SQL create table drop table insert into table values ( ) delete from table where update table set a to v where

More information

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

Midterm Exam #2 (Version C) CS 122A Spring 2018 NAME: SEAT NO.: STUDENT ID: Midterm Exam #2 (Version C) CS 122A Spring 2018 Max. Points: 100 (Please read the instructions carefully) Instructions: - The total time for the exam is 50 minutes; be sure

More information

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)

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) CS127 Homework #3 Warmup #1 Consider the following set of functional dependencies, F, for the schema R(A, B, C, D, E) 1. Find the candidate keys for the schema R. AB, C, D, and EA 2. Compute the closure,

More information

Examination paper for TDT4145 Data Modelling and Database Systems

Examination paper for TDT4145 Data Modelling and Database Systems Department of Computer and Information Science Examination paper for TDT4145 Data Modelling and Database Systems Academic contact during examination: Svein Erik Bratsberg: 99539963 Roger Midtstraum: 99572420

More information

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

Outline. Database Management Systems (DBMS) Database Management and Organization. IT420: Database Management and Organization Outline IT420: Database Management and Organization Dr. Crăiniceanu Capt. Balazs www.cs.usna.edu/~adina/teaching/it420/spring2007 Class Survey Why Databases (DB)? A Problem DB Benefits In This Class? Admin

More information

Relational Algebra. Relational Query Languages

Relational Algebra. Relational Query Languages Relational Algebra Davood Rafiei 1 Relational Query Languages Languages for describing queries on a relational database Three variants Relational Algebra Relational Calculus SQL Query languages v.s. programming

More information

Triggers- View-Sequence

Triggers- View-Sequence The Islamic University of Gaza Faculty of Engineering Dept. of Computer Engineering Database Lab (ECOM 4113) Lab 9 Triggers- View-Sequence Eng. Ibraheem Lubbad Triggers: A trigger is a PL/SQL block or

More information

Chapter 4: Intermediate SQL

Chapter 4: Intermediate SQL Chapter 4: Intermediate SQL Chapter 4: Intermediate SQL Join Expressions Views Transactions Integrity Constraints SQL Data Types and Schemas Authorization Joined Relations Join operations take two relations

More information

CS2300: File Structures and Introduction to Database Systems

CS2300: File Structures and Introduction to Database Systems CS2300: File Structures and Introduction to Database Systems Lecture 9: Relational Model & Relational Algebra Doug McGeehan 1 Brief Review Relational model concepts Informal Terms Formal Terms Table Relation

More information

Lab # 9. Java to Database Connection

Lab # 9. Java to Database Connection Islamic University of Gaza Faculty of Engineering Department of Computer Engineering ECOM 4113: Lab # 9 Java to Database Connection Eng. Haneen El-Masry December, 2014 2 Objective In this lab, we turn

More information

Working with Databases and Java

Working with Databases and Java Working with Databases and Java Pedro Contreras Department of Computer Science Royal Holloway, University of London January 30, 2008 Outline Introduction to relational databases Introduction to Structured

More information

The Relational Model. Week 2

The Relational Model. Week 2 The Relational Model Week 2 1 Relations A relation is a more concrete construction, of something we have seen before, the ER diagram. name S.S.N students street city A relation is (just!) a table! We will

More information

Full file at

Full file at SQL for SQL Server 1 True/False Questions Chapter 2 Creating Tables and Indexes 1. In order to create a table, three pieces of information must be determined: (1) the table name, (2) the column names,

More information

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

Homework #4 1. Suppose that each of the following Update operations is applied directly to the database state shown in Figure 5.6. Homework #4 1. Suppose that each of the following Update operations is applied directly to the database state shown in Figure 5.6. Discuss all integrity constraints violated by each operation, if any,

More information

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

3 February 2011 CSE-3421M Test #1 p. 1 of 14. CSE-3421M Test #1. Design 3 February 2011 CSE-3421M Test #1 p. 1 of 14 CSE-3421M Test #1 Design Sur / Last Name: Given / First Name: Student ID: Instructor: Parke Godfrey Exam Duration: 75 minutes Term: Winter 2011 Answer the following

More information

CSE 544 Principles of Database Management Systems

CSE 544 Principles of Database Management Systems CSE 544 Principles of Database Management Systems Lecture 1 - Introduction and the Relational Model 1 Outline Introduction Class overview Why database management systems (DBMS)? The relational model 2

More information

SQL DATA DEFINITION LANGUAGE

SQL DATA DEFINITION LANGUAGE SQL DATA DEFINITION LANGUAGE DATABASE SCHEMAS IN SQL SQL is primarily a query language, for getting information from a database. DML: Data Manipulation Language SFWR ENG 3DB3 FALL 2016 MICHAEL LIUT (LIUTM@MCMASTER.CA)

More information

Chapter Five Physical Database Design

Chapter Five Physical Database Design Chapter Five Physical Database Design 1 Objectives Understand Purpose of physical database design Describe the physical database design process Choose storage formats for attributes Describe indexes and

More information

CS W Introduction to Databases Spring Computer Science Department Columbia University

CS W Introduction to Databases Spring Computer Science Department Columbia University CS W4111.001 Introduction to Databases Spring 2018 Computer Science Department Columbia University 1 in SQL 1. Key constraints (PRIMARY KEY and UNIQUE) 2. Referential integrity constraints (FOREIGN KEY

More information

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

1- a> [5pts] Create the new table by writing and executing a full SQL DDL statement based on the following schema: 1. [20pts] To track the history of financial information changes such as a driver s bank account, you are going to create a table to store the history of all bank account numbers. Once created, this table

More information

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

CS 200. Lecture 06. Database Introduction. Database Introduction. CS 200 Winter 2018 CS 200 Lecture 06 1 Miscellaneous Notes Abbreviations aka also known as DBMS DataBase Management System mutatis mutantis with the necessary changes having been made 2 Please read and highlight BEFORE lab

More information

PLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science

PLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science PLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science APRIL 2015 EXAMINATIONS CSC 343 H1S Instructor: Horton and Liu Duration 3 hours PLEASE HAND IN Examination Aids: None Student Number: Family

More information

SQL: A COMMERCIAL DATABASE LANGUAGE. Data Change Statements,

SQL: A COMMERCIAL DATABASE LANGUAGE. Data Change Statements, SQL: A COMMERCIAL DATABASE LANGUAGE Data Change Statements, Outline 1. Introduction 2. Data Definition, Basic Constraints, and Schema Changes 3. Basic Queries 4. More complex Queries 5. Aggregate Functions

More information

Databases 1. Defining Tables, Constraints

Databases 1. Defining Tables, Constraints Databases 1 Defining Tables, Constraints DBMS 2 Rest of SQL Defining a Database Schema Primary Keys, Foreign Keys Local and Global Constraints Defining Views Triggers 3 Defining a Database Schema A database

More information

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

Data! CS 133: Databases. Goals for Today. So, what is a database? What is a database anyway? From the textbook: CS 133: Databases Fall 2018 Lec 01 09/04 Introduction & Relational Model Data! Need systems to Data is everywhere Banking, airline reservations manage the data Social media, clicking anything on the internet

More information

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

Overview. Database Application Development. SQL in Application Code. SQL in Application Code (cont.) Overview Database Application Development Chapter 6 Concepts covered in this lecture: SQL in application code Embedded SQL Cursors Dynamic SQL JDBC SQLJ Stored procedures Database Management Systems 3ed

More information

Database Application Development

Database Application Development Database Application Development Chapter 6 Database Management Systems 3ed 1 Overview Concepts covered in this lecture: SQL in application code Embedded SQL Cursors Dynamic SQL JDBC SQLJ Stored procedures

More information

Database Application Development

Database Application Development Database Application Development Chapter 6 Database Management Systems 3ed 1 Overview Concepts covered in this lecture: SQL in application code Embedded SQL Cursors Dynamic SQL JDBC SQLJ Stored procedures

More information

CS 474, Spring 2016 Midterm Exam #2

CS 474, Spring 2016 Midterm Exam #2 CS 474, Spring 2016 Midterm Exam #2 Name: e-id: @dukes.jmu.edu By writing your name, you acknowledge the following honor code statement: I have neither given nor received unauthorized assistance on this

More information

Chapter 4: Intermediate SQL

Chapter 4: Intermediate SQL Chapter 4: Intermediate SQL Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use 4.1 Join Expressions Let s first review the joins from ch.3 4.2 1 SELECT * FROM student, takes

More information

This lecture. Basic Syntax

This lecture. Basic Syntax This lecture Databases - Database Definition This lecture covers the process of implementing an ER diagram as an actual relational database. This involves converting the various entity sets and relationship

More information