Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2006
    Posts
    2

    Question Unanswered: subset queries . please help me!!

    item Table

    tuple itemid name weight price type
    i1 1 soap 40 20 Non-Eatable
    i2 2 face powder 250 70 Non-Eatable
    i3 3 bread 60 15 Eatable
    i4 4 tooth paste 150 50 Non-Eatable
    i5 5 jam 35 65 Eatable
    i6 6 chips 25 18 Eatable
    i7 7 hair oil 100 35 Non-Eatable
    i8 8 sauce 75 40 Eatable
    i9 9 perfume 60 100 Non-Eatable
    i10 10 candy 20 50 Eatable

    Consider an Item relation in a grocery shop: (ItemId, Name, Weight, Price, Type) where ItemId is the unique id of the item, Name, Weight and Price denote the name, weight of the item in grams and the price of the item in Dollars respectively. The domain of Type is { "Eatable","Non- Eatable"}

    shop Table

    tuple itemid name weight rating
    S1 1 M.G. Road 20 4.5
    S2 2 Airport 15 3.9
    S3 3 Downing Street 18 4.6
    S4 4 S.D. Road 12 4.8
    S5 5 Highway Road 17 2.0

    Consider a relation Shop: (ShopId,Location, Distance,Rating) where ShopId, Location and Distance are the id of the shop, location of the shop and the distance of the shop from a city center in Kilometers respectively. Rating is the popular rating of the shop given in a survey.

    query 1 .What are the shops which are visited by ANY customer if the distance traveled by him is between 31 and 40 and if he visits only shops whose rating is more than 4.0?. and .What are the shops which are visited by EVERY customer if the distance traveled by him is between 31 and 40 and if he visits only shops whose rating is more than 4.0?. In the first query, the required answer is the union of the subsets which satisfy the given conditions where as in the second query it is the intersection of them. The main subset query generates two subsets: {{s1,s3},{s3,s4}} Hence the result of the union is {s1,s3,s4} and that of the intersection is {s3}.

    query 2 .What are the shops a customer might visit if the total distance traveled is between 30 and 36 and the rating of the shops visited is between 3.5 and 4.7 or if the total rating of the shops visited is between 5.5 and 7.0 and if the distance of any shop to be visited is between 14 and 19?. and .What are the shops a customer might visit if the total distance traveled is between 30 and 36 and the rating of the shops visited is between 3.5 and 4.7 and if the total rating of the shops visited is between 5.5 and 7.0 and if the distance of any shop to be visited is between 14 and 19?.The results of the sub-queries (a) and (b) are {{s1,s2},{s2,s3}} and {{s2,s5},{s3,s5}} respectively. The result of the cross union query is {{s1,s2,.s5},{s2,s3,s5},{s1,s2,s3,s5}} and the result of the cross intersection operation is {{s2},{s3}}.For the subset union query, the two queries are combined and the result of the query is {{s1,s2},{s2,s3},{s2,s5},{s3,s5}}

    query 3 Consider the Item relation and the Shop relation, consider the query: .Assuming that every item is available in every shop, give all the possibilities in which a customer visits a set of shops such that the distance of each shop is between 14 and 19 and the sum of the rating of the shops visited is between 5.5 and 7.0 and he buys the items whose price is less than 30 and the total weight of the items bought is between 60 and 90?.The result of the first part of the query is {{s2,s5},{s3,s5}} and the result of the second part of the query is {{i1,i6},{i3,i6}}. The cross Cartesian product computes the Cartesian product of every pair of subsets taking one subset from each. Hence there will be four subsets in the output.

    PLEASE HELP me WITH THeSe QUERY.... ( I am using oracle 10G Release 1 )
    Last edited by j.syafrizal; 01-22-06 at 05:18.

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    This is a "please do my schoolwork for me" question. My answer is "no". Sorry.

    When you have actually tried something yourself and still can't do it, post what you have done and someone may help correct your error.

  3. #3
    Join Date
    May 2004
    Location
    BA [ARG]
    Posts
    137
    Get serious, man!
    That seems like a school test! Is not that difficult, try to solve it, otherwise you won't get paid when you grow up!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •