Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 3336C9FBD32 for ; Thu, 14 Jun 2007 08:21:20 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 32082-03 for ; Thu, 14 Jun 2007 08:21:08 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from wx-out-0506.google.com (wx-out-0506.google.com [66.249.82.228]) by postgresql.org (Postfix) with ESMTP id 128E79FB7CC for ; Thu, 14 Jun 2007 08:21:07 -0300 (ADT) Received: by wx-out-0506.google.com with SMTP id s16so442781wxc for ; Thu, 14 Jun 2007 04:21:07 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=WVrRfChHFomaEg3+O6AgXfE1eee4dPqxCqIDHKYRxtoEhtAtLuRicIBoHD0lqjXT43Lv9xxhIPZCm8udu7DPTaJDc+B/qgGAb4p64m4l6lfk3MNzsHV8Dc7pCI4mVwz3AgIW53gx0KZOD5Oi+z02yzzY0e1siIQGjSp/fZEegdA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=qVKskJYU9IPnKj2F0S8wv2BROvK+AdPPeeeitIrIk90S3K1o6lqCXiiS6ge+L6bjbullSAr0op6/rXTqBV8IrcTHAlu2+FPJEMjE/RylahsKcEPidKeQh2Hm/Cja5AZUqdhPD07FfBbfSDUPgbrn1UfipRjO+dbEGhrxrDJAyzQ= Received: by 10.90.98.3 with SMTP id v3mr1264484agb.1181820066891; Thu, 14 Jun 2007 04:21:06 -0700 (PDT) Received: by 10.90.93.12 with HTTP; Thu, 14 Jun 2007 04:21:06 -0700 (PDT) Message-ID: <2049e51a0706140421u1ef40ab7m7281ca91457396df@mail.gmail.com> Date: Thu, 14 Jun 2007 12:21:06 +0100 From: "Salman Tahir" To: pgsql-sql@postgresql.org Subject: Organization of tables MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=BAYES_50=0.001 X-Spam-Level: X-Archive-Number: 200706/104 X-Sequence-Number: 28594 Hi, I have a question regarding the organization of a table I want to create in my database: I have the following setup: Table Fragments (simplified example): Primary key = {mass} Approach (1) fragment | mass (of fragment) | peptide ---------------+--------------------------------+-------------- A | x | Peptide1, Peptide2 Q | y | Peptide1 K | z | Peptide 2, Peptide3 The idea here is that a peptide can be composed of many fragments e.g. Peptide 2 is made up of fragments A and K; Peptide1 is made up of A and Q and so on. My idea is to create an index on the mass column and be able to retrieve all Peptides that contain a certain fragment mass e.g SELECT peptide FROM Fragments WHERE mass = x; Should give me: Peptide1, Peptide2 The alternative way I have thought of to organize this table is to have something as follows: Approach (2) Primary Key = {fragment, mass, peptide} fragment | mass (of fragment) | peptide ---------------+--------------------------------+-------------- A | x | Peptide1 A | x | Peptide2 Q | y | Peptide1 K | z | Peptide 2 K | z | Peptide 3 If I consider 2500 unique fragments then, using approach (1), table Fragments will hold 2,500 tuples. If I consider the same number of fragments then table Fragments using approach 2 holds 15,000 tuples. I have considered using approach (1) whereby I would have less tuples to search but if I wanted to access the peptides they belong to I would retrieve the list of corresponding peptides e.g the string "Peptide1, Peptide2" and process it in my program. However this seems like a hack around the way a database table should be organised. The problem increases further when I have to scale up and consider more unique fragments (>2500). Any help on how best to structure such data would be mostly appreciated. - Salman Tahir