|
/afs/ir/class/cs145/bin/submit-challengeMake sure you are in the directory on your Leland account that contains the solution file, then execute the script by typing "/afs/ir/class/cs145/bin/submit-challenge". After a few prompts, the script will copy your solution file (only if it is appropriately named) to our private submissions directory, along with a timestamp. You may resubmit your solutions as many times as you like, however only the latest file and the latest timestamp are saved, and those are what we will use for grading your work and determining late penalties. Submissions via email will not be accepted.
RENAME[NewName(NewID)](PROJECT[ID]((SELECT[Age<18](Students)) JOIN[Students.ID = Classes.ID] (SELECT[Time>1200](Classes))))Needless to say, we prefer the correct symbols and subscripting if possible.
Partners are not permitted. Problems must be completed individually.
|
Prof(name, phone, email, dCode) Dept(code, name, building, numFac)We will use the following sample data for these relations.
(Widom, 123-4567, widom@cs, CS) (Widom, 123-4567, widom@ee, EE) (Ullman, 987-6543, ullman@cs, CS)In relation Dept:
(CS, Computer Science, Gates, 40) (EE, Electrical Engineering, Packard, 55) (ME, Mechanical Engineering, MERL, 45)Do not make any assumptions about the data except as stated in the questions.
(a) Specify a single DTD that allows data from any relational schema (one or more relations) to be stored as an XML document valid with respect to that DTD. (That is, the element structure of the XML will not be derived from the relational schema, since it needs to work for every schema.) Show how the sample data above would be encoded in XML corresponding to your DTD.
(b) Specify an algorithm for translating a relational schema (one or more relations) into a single XML DTD, where in this case the element structure (i.e., the tags) in the XML can reflect the relational schema. Show how the sample data above would be encoded in XML corresponding to your DTD. You may specify your algorithm using any kind of high-level pseudocode that you like.
(c) Suppose you have the additional information that every value appearing in attribute Prof.dCode appears exactly once in Dept.code. You don't have to modify your translation algorithm, but illustrate what might be considered a "better" XML structure for the sample data than the structure produced by your algorithm in (2).
Prof(name, phone, email, dCode) Dept(code, name, building, numFac)For this problem you may assume that (name,dCode) is a key for relation Prof, and code is a key for relation Dept.
For each of the following queries, either write the query as a relational algebra expression or explain why it cannot be written in relational algebra.
(a) Find the names of all departments where the number of professors listed for that department does not match the value in attribute numFac for that department.
(b) Assuming the numFac attribute value is correct (i.e., ignoring the Prof relation altogether), find the name of the department with the smallest number of faculty. In the case of ties, return names for all of the smallest departments.