MESSAGE
DATE | 2014-12-12 |
FROM | Ruben Safir
|
SUBJECT | Subject: [LIU Comp Sci] Re: turning attibute values into relations?
|
From owner-learn-outgoing-at-mrbrklyn.com Fri Dec 12 17:35:58 2014 Return-Path: X-Original-To: archive-at-mrbrklyn.com Delivered-To: archive-at-mrbrklyn.com Received: by mrbrklyn.com (Postfix) id D4043161166; Fri, 12 Dec 2014 17:35:57 -0500 (EST) Delivered-To: learn-outgoing-at-mrbrklyn.com Received: by mrbrklyn.com (Postfix, from userid 28) id BD29316116D; Fri, 12 Dec 2014 17:35:57 -0500 (EST) Delivered-To: learn-at-nylxs.com Received: from mailbackend.panix.com (mailbackend.panix.com [166.84.1.89]) by mrbrklyn.com (Postfix) with ESMTP id EB570161166 for ; Fri, 12 Dec 2014 17:35:56 -0500 (EST) Received: from [10.0.0.42] (unknown [96.57.23.82]) by mailbackend.panix.com (Postfix) with ESMTPSA id 9FE1814EC2; Fri, 12 Dec 2014 17:35:55 -0500 (EST) Message-ID: <548B6DD4.4080909-at-panix.com> Date: Fri, 12 Dec 2014 17:36:04 -0500 From: Ruben Safir User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: learn-at-nylxs.com, Ping-Tsai Chung Subject: [LIU Comp Sci] Re: turning attibute values into relations? References: <5489C901.7040301-at-mrbrklyn.com> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Sender: owner-learn-at-mrbrklyn.com Precedence: bulk Reply-To: learn-at-mrbrklyn.com
On 12/12/2014 06:50 AM, Lennart Jonsson wrote: > On 2014-12-11 17:40, ruben safir wrote: >> I know that usenet is bad for homework but this problem is driving me >> crazy >> >> I need some expertise outside my current ring of contacts. >> >> This question is >> (e) Retrieve the names of employees who work on every project >> >> Which I think is saying find the employees that work on ALL projects. >> > > What you are looking for is relational division. Using the universal > quantifier ? (not sure if this i shown correkt so I'll use Forall below) > > Forall x:p(x) where x is project and p is "employee works on". This is > not directly supported in SQL, but can be rewritten using Existential > quantification: > > Forall x:p(x) <=> NOT Exists x : NOT p(x) > > I.e. employees for which there is no project such that the employee is > not working on it. This is relatively simple to transform to SQL. > > For SQL you could also use an approach with employees that work on the > same number of projects as there are projects > > > > /Lennart > > > > >> How do you turn a relationship into an atribute that can be quried on >> >> This is the relavent relations (tables) >> SQL> descr employee >> Name Null? Type >> ----------------------------------------- -------- >> ---------------------------- >> FNAME NOT NULL VARCHAR2(20) >> MINIT CHAR(1) >> LNAME NOT NULL VARCHAR2(20) >> SSN NOT NULL NUMBER(9) >> BDATE NOT NULL DATE >> ADDRESS NOT NULL VARCHAR2(50) >> SEX NOT NULL CHAR(1) >> SALARY NOT NULL FLOAT(12) >> SUPERSSN NUMBER(9) >> DNO >> NUMBER(2) >> >> >> SQL> descr PROJECT >> Name Null? Type >> ----------------------------------------- -------- >> ---------------------------- >> PNAME NOT NULL VARCHAR2(20) >> PNUMBER NOT NULL NUMBER(2) >> PLOCATION NOT NULL VARCHAR2(15) >> DNUM >> NUMBER(2) >> SQL> descr works_on >> Name Null? Type >> ----------------------------------------- -------- >> ---------------------------- >> ESSN NOT NULL NUMBER(9) >> PNO NOT NULL NUMBER(2) >> HOURS FLOAT(5) >> >> >> >> So you want a query that includes off the essn's in workson that >> associated with all the possible pno and match pnumbers in projects. >> >> I tried this in SQL and in relational algebra and I can't see a path to >> a solution. >> >> Ruben >> >
|
|