hw2Sol

hw2Sol - Fall 2006 CS143 3.1 Answer: (a) we count the...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Fall 2006 CS143 HW 2 Solution 3.1 Answer: (a) we count the owners not the accidents . .. SELECT count(distinct O.driver_id) FROM participated as P, accident as A, owns as O WHERE A.date >='1989-01-01' AND A.date < '1990-01-01' AND P.report_number=A.report_number AND P.car=O.license (b) add a new accident: first the report and then the participated record referring to the report. All the rest is in place. INSERT INTO accident value (8872, 2006-08-14, `Santa Monica`) INSERT INTO participated value (0023,45678, 8872, 956) (c) Delete the Mazda of John Smith DELETE FROM owns WHERE driver_id in (SELECT driver_id FROM person WHERE name='John Smith') DELETE FROM car WHERE model= `mazda` AND license IN ( SELECT license FROM OWNS as O, person as P WHERE O.driver_id=P.driver_id AND P.name= `John Smith' ) 3.9 Consider the employee database of Figure 3.12, where the primary keys are underlined. Give an expression in SQL for each of the following queries. a.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/28/2010 for the course CS 143 taught by Professor Zaniolo during the Fall '01 term at UCLA.

Page1 / 2

hw2Sol - Fall 2006 CS143 3.1 Answer: (a) we count the...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online