## Combinatorial problem

From: Srinivas Iyyer pgsql-novice(at)postgresql(dot)org Combinatorial problem 2005-11-29 23:44:10 20051129234410.74479.qmail@web31601.mail.mud.yahoo.com (view raw or whole thread) 2005-11-24 15:53:32 from Peter George  2005-11-27 03:07:00 from   2005-11-29 23:44:10 from Srinivas Iyyer    2005-11-30 01:16:01 from Michael Fuhr    2005-11-30 11:46:03 from Sean Davis     2005-11-30 13:26:38 from Srinivas Iyyer      2005-11-30 13:43:12 from Sean Davis       2005-11-30 13:57:42 from Srinivas Iyyer        2005-11-30 14:09:48 from Sean Davis         2005-11-30 18:40:43 from Srinivas Iyyer          2005-11-30 18:51:35 from Marcus Engene           2005-11-30 19:12:57 from Sean Davis           2005-11-30 21:05:27 from Srinivas Iyyer            2005-11-30 21:32:52 from Marcus Engene             2005-11-30 23:37:36 from Marcus Engene        2005-11-30 14:35:58 from Marcus Engene 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?

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

```

### pgsql-novice by date

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