project1-SQL
project1-SQL
Term Project
Spring 2020
1 Database requirements
Tasks:
Deliverables: None.
1
• The database also keeps the duration of time each user worked on a project. Notice
that this value can be calculated easily based on the start-date and end-date fields
described above.
• Every project is coordinated by a user. A coordinator may coordinate multiple projects
concurrently.
• The most important part of the database contains access logs of users. Whenever a
user accesses a document, an access log entry is created by the system.
• Each access log entry contains the following information:
(a) type of access: either ‘R’ for read, or ‘W’ for write, ‘RW’ for read and write,
(b) event timestamp: the date and time when the user accessed the document, and,
(c) a field called “difference”.
• The field “difference” is textual (i.e., is a string) and contains all the details needed
for undoing an edit operation by a user. Think of this field as an incremental backup
of the document.
• Over time, it is natural that a user will have multiple access log entries for a document.
• However, a user cannot have two access log entries on the same document with the
same timestamp.
2
Figure 1: ER diagram
2 Implementation of the DB
Tasks:
(a) Implement the relational schema in Fig. 2 on the DBMS of your choice.
(b) Once the implementation is over, populate every table with a reasonable
number of tuples (at least 5 for tables representing entities and 10 for tables
representing relationships ).
(c) Write SQL queries retrieving the information specified below.
3
User Project
LogEntry WorksFor
UName AbsPath TS Type Diff UName PName PVersion StartDate EndDate
Queries (replace the variables P, D, U, etc. with a suitable value from the domain):
(1) Select the last names of users working on project P.
(2) Select the count of access log entries on document D.
(3) Select the amount of time user U spent on project P.
(4) Select the first name and last name of users that store a personal file on the system.
A file that is not part of any projects is a personal file.
(5) Select the coordinator that coordinates the highest number of projects.
(6) Select the path to the most recently updated document.
(7) Select the number of documents owned by user U.
(8) Select the users that work on all projects coordinated by user U.
(9) Select the project that has the highest number of versions.
(10) For each user-project pair, list the number of access log entries. Order the result set
by count in descending order.