CSE 344 Final: CSE 344 UW Final Exam Solution 12 Winter

39 views26 pages
31 Jan 2019
School
Course
Professor

Document Summary

1 sql, relational calculus, relational algebra: (60 points) The following database constains information about email messages in a large organiza- tion: Assume that pid"s and eid s are integers, and name and body are char- acter strings (choose an appropriate length). Solution: create table person( pid int primary key, name varchar(20)); create table email( eid int primary key, pidfrom int references person, tid int, body varchar(1024), length int); create table emailto( eid int references email, pidto int references person); Emailto(eid,pidto) (b) (10 points) for each email thread, compute the total number of distinct recipients of emails in that thread. For example, if the thread contains 100 emails, and all emails went to only one recipient, then your query should answer 1 for that thread id. Solution: select e. tid, count(distinct e2. pidto) from email e, emailto e2 where e. eid = e2. eid group by e. tid. Write a sql query that computes the total number of circles in the database.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers

Related Documents