Skip site navigation (1) Skip section navigation (2)

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: (view raw, whole thread or download thread mbox)
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

The question that I asked is:

For a given target what are the unique Drugs (such as
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_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_id | target_name
1       |  T1
2       |  T2
3       |  T3

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


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

thanks again.

Yahoo! Mail - PC Magazine Editors' Choice 2005

In response to


pgsql-novice by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group