1) There are a few possible solutions. What's important to understand that instances exist independently of orders and that instances are then assigned to orders and shipments. orderdest(orderid, shipto) orderid is the key; shipto is destination loc. orderitem(orderid, item, quantity) (orderid, item) is key location(loc, address) loc is key shipment_loc(shipid, source_loc, dest_loc) shipid is key [shipid, source_loc could also be the key; ] ordership(orderid, shipid) -- both together are key [It's conceivable to combine ordership and shipment.] locitem(item, instanceid, loc) item and instanceid (or conceivably just instanceid) is the key shipment(shipid, item, instanceid) shipid and instanceid constitute the key [It's also possible to put these tables together] orderinstance(orderid, item, istanceid) orderid, item, istanceid constitue the key (or conceivably just orderid, instanceid) 2) -- For a given orderid O. Select all items that are in a shipment and their source location select item, instanceid, address from location L, shipment S, shipment_loc SL, ordership OS where S.shipid = OS.shipid and S.shipid = SL.shipid and S.source_loc = L.loc and OS.orderid = @O -- For a given orderid O. Select all items that are in a certain location (haven't been shipped yet) select item, instanceid, address from location L, locitem LI. orderinstance OI where LI.loc = L.loc and OI.orderid = @O and OI.instanceid = LI.instanceid 3) --- The orderid used in the query is: O ship to location: X. As we want to get all the instances with the maximum distance we first create a temporary table containing the distances of the order. Also possible to get the shipto location from orderdest. create temporary table temp select D.dist from locitem LI, distance D, orderinstance OI where OI.orderid = @O and OI.instanceid = LI.instancedid D.loc1 = I.loc and D.loc2 = @X; --- Now select all instances with distance equal to max select item, instanceid from locitem LI, distance D, orderinstance OI where OI.orderid = @O and OI.instanceid = LI.instancedid D.loc1 = I.loc and D.loc2 = @X and D.dist = (select max(dist) from temp); It is also possible to perform the above query without a temporary table and just with a more complex sub-select statement. 4) a) The set is already minimal. b) AB is a key. BE is also a key. c) Combining the FDs with union rule we get: A -> CE B -> C CE -> DA DE -> C We can now create the tables: (B,C), (C, E, D, A) which contain all relationships. But need to add a superkey. So we get: (A, B), (B,C), (C, E, D, A) An additional decomposition is: (B,E) (B,C), (C, E, D, A) Two other alternatives: (A, B), (B,C), (C, E, D), (C, E, A) (B, E), (B,C), (C, E, D), (C, E, A) d) A -> C, B -> C, DE -> C, C -> E, C -> D, C -> A Another answer: A -> C, B -> C, A->E, C->D, DE->C, C->A 5) An example is: A --> B, AB --> C, C --> B, Step 1 can't remove any FDs. Step 2 can remove: B from AB-->C (as A-->B). Thus we get: A --> B, A --> C, C --> B, And now Step 1 can remove A --> B 6) The most basic decompisition is at least a separation of the global properties characterizing the room from the reservation itself. Thus a basic decompistion would be: inventory(hotelid, roomtypeid, date, numbertaken) - (hotelid, roomtypeid, date) is a key roomtype(hotelid, roomtypeid, numberavailable, description) - (hotelid, roomtypeid) is a key. If roomtypeid is defined as globaly unique an alternative solution is: inventory(roomtypeid, date, numbertaken) - (roomtypeid, date) is a key roomtype(roomtypeid, hotelid, numberavailable, description) - (roomtypeid) is a key. 7) { for $i in doc("hispo.xml")//item return {$i/@partNum}{$i/USPrice/text() * $i/quantity/text()} } Here is another version with variables: { for $i in doc("hispo.xml")//item let $p := $i/USPrice/text() let $q := $i/quantity/text() let $n := $i/@partNum return: {$n} { $p*$q } } The result is: 148.95 79.96