Combinatorial problem

From: Srinivas Iyyer <srini_iyyer_bio(at)yahoo(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Combinatorial problem
Date: 2005-11-29 23:44:10
Message-ID: 20051129234410.74479.qmail@web31601.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Dear Group,
I have a piece of data that is more relational.

The following is an illustrative example:

Drug Target
m1 T1
m2 T1
m3 T2
m2 T3
m2 T2
m4 T4
m1 T4
m5 T1
m5 T5
m6 T3
m6 T4
m6 T5
m6 T6
.. ..
.. ..
m3200 T9000

In this example m1 drug targets are T1 and T4.

m2 drug targets are T1,T2,T3.

Likewise, I have over 3000 drugs and over 9000
targets.

The question that I asked is:

For a given target what are the unique Drugs (such as
m1,m4,m6)
For a group of related drugs (m1,m2 and m3) what are
the targets.

I am novice programmer in python and R-statistical
language. I attempted in both these and it is proving
very very difficult.

I chose a database approach.

I created 3 tables:

A drug table 'Drug'
A target table 'Target'
A combined table with mapping information 'Comb'

(in comb table I have the mapping information as
illustrated in the above example)

Drug:
--------------------
drug_id | drug_name
--------------------
1 | m1
2 | m2
3 | m3

Here drug_id is primary key and made as serial.
drug_name is varchar(10)
Target:

--------------------
target_id | target_name
--------------------
1 | T1
2 | T2
3 | T3

target_id is 'Serial' primary key
Target_name is varchar(20)

Comb:

--------------------
drug_id | target_ID
--------------------
1 | 1
2 | 1
1 | 2
1 | 4
1 | 432

Now my question is how can I ask SQL the question:

For T3 what are the Drugs ?
For T4 what are the drugs?

For a group of drugs m1,m3,m5 what are the targets?

Can any one please help me. Thanks

I am stuck and my progress is depended on ur kind
suggestion.

thanks again.
Sr



__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Oliver Elphick 2005-11-29 23:47:23 Re: saving a query and reults to a file.
Previous Message operationsengineer1 2005-11-29 23:21:26 Re: saving a query and reults to a file.