How Can Relational Algebra Be Used to Find Diseases With Only One Medication?

  • Thread starter Thread starter Shaitan00
  • Start date Start date
  • Tags Tags
    Algebra
AI Thread Summary
The discussion focuses on formulating a relational algebra statement to identify diseases that have only one corresponding medication from a provided TREATMENT table. The example illustrates that diseases like CANCER and HIV should be returned, while FLU is excluded due to having multiple medications. Participants suggest using aggregate functions to count medications per disease, but the challenge lies in filtering results to show only those with a count of one. The conversation also touches on the distinction between SQL's HAVING and WHERE clauses, emphasizing the need for a post-aggregation filter. Overall, the thread seeks clarity on applying relational algebra for this specific query.
Shaitan00
Messages
13
Reaction score
0
I am trying to write the RELATIONAL ALGEBRA statement for a query defined as follows:
"Find the diseases for which there is only one medication"

I have a table TREATMENT with two attributes, DISEASE & MEDICATION
TREATMENT (disease, medication)

This table holds a list of diseases and corresponding medication, of course for each diseases that can potentially be multiple medications, and for some only one. For example assume you have something that resembles the following:

Disease | Medication
--------------------
FLU | med1
FLU | med2
CANCER | med3
HIV | med4
FLU | med5

In this case you would expect to get CANCER & HIV (as they only have 1 corresponding medication) whereas FLU would be excluded because it has 3... (etc...)

Any help would be greatly appreciated...
Thanks,
 
Last edited:
Mathematics news on Phys.org
I was looking at that already - but couldn't figure it out...
WIth those expressions I can easily determine the COUNT for each but how do I list only the diseases that have a count = 1?

Thanks,
 
SQL uses a HAVING keyword for such cases, which is nothing but a select operation on the result of the aggregation. I believe the only reason to define in SQL a different keyword than WHERE was to distinguish between a select operation after the aggregation (HAVING), as opposed to before (WHERE).
 
Fermat's Last Theorem has long been one of the most famous mathematical problems, and is now one of the most famous theorems. It simply states that the equation $$ a^n+b^n=c^n $$ has no solutions with positive integers if ##n>2.## It was named after Pierre de Fermat (1607-1665). The problem itself stems from the book Arithmetica by Diophantus of Alexandria. It gained popularity because Fermat noted in his copy "Cubum autem in duos cubos, aut quadratoquadratum in duos quadratoquadratos, et...
Insights auto threads is broken atm, so I'm manually creating these for new Insight articles. In Dirac’s Principles of Quantum Mechanics published in 1930 he introduced a “convenient notation” he referred to as a “delta function” which he treated as a continuum analog to the discrete Kronecker delta. The Kronecker delta is simply the indexed components of the identity operator in matrix algebra Source: https://www.physicsforums.com/insights/what-exactly-is-diracs-delta-function/ by...
Thread 'Imaginary Pythagorus'
I posted this in the Lame Math thread, but it's got me thinking. Is there any validity to this? Or is it really just a mathematical trick? Naively, I see that i2 + plus 12 does equal zero2. But does this have a meaning? I know one can treat the imaginary number line as just another axis like the reals, but does that mean this does represent a triangle in the complex plane with a hypotenuse of length zero? Ibix offered a rendering of the diagram using what I assume is matrix* notation...
Back
Top