Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 3FA639FB466 for ; Mon, 30 Jul 2007 04:21:40 -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 47329-09 for ; Mon, 30 Jul 2007 04:21:38 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) by postgresql.org (Postfix) with ESMTP id 479229FB449 for ; Mon, 30 Jul 2007 04:21:37 -0300 (ADT) Received: from server3.office.archonet.com (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id 419F1143990; Mon, 30 Jul 2007 08:21:35 +0100 (BST) Received: from [192.168.1.36] (dell36.office.archonet.com [192.168.1.36]) by server3.office.archonet.com (Postfix) with ESMTP id 0344E274060; Mon, 30 Jul 2007 08:21:34 +0100 (BST) Message-ID: <46AD917E.3050902@archonet.com> Date: Mon, 30 Jul 2007 08:21:34 +0100 From: Richard Huxton User-Agent: Thunderbird 2.0.0.0 (X11/20070326) MIME-Version: 1.0 To: Jay Kang Cc: pgsql-performance@postgresql.org Subject: Re: Questions on Tags table schema References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200707/417 X-Sequence-Number: 26101 Jay Kang wrote: > Hello, > > I'm currently trying to decide on a database design for tags in my web > 2.0application. The problem I'm facing is that I have 3 separate > tables > i.e. cars, planes, and schools. All three tables need to interact with the > tags, so there will only be one universal set of tags for the three tables. > > I read a lot about tags and the best articles I found were: > > Road to Web 2.0 ( http://wyome.com/docs/Road_to_Web_2.0:_The_Database_Design ) And what in particular recommended this to you? > Currently, this is my DB design: > > Cars (carid, carname, text, etc.) > Planes (planeid, planename, text, etc.) > Schools (schoolname, text, etc.) <------ School does not take int as primary > key but a varchar. You don't mention a primary-key here at all. You're not thinking of using "schoolname" are you? > Tags (tagid, tagname, etc) > > --- Now here is where I have the question. I have to link up three separate > tables to use Tags > --- So when a new car is created in the Cars table, should I insert that > carID into the TagsItems table > --- as itemID? So something like this? > > TagsItems > ( > tagid INT NOT NULL REFERENCES Tags.TagID, > itemid INT NULL, <---- really references Cars.carID and Planes.planeID > schoolname varchar NULL <---- Saves the Schools.schoolname > itemid + tagId as Unique > ) What's wrong with the completely standard: car_tags (carid, tagid) plane_tags (planeid, tagid) school_tags (schoolid, tagid) > I also have a question on the schoolname field, because it accepts varchar > not integer. There seems to be some design that would better fit my needs. > I'm asking you guys for a little assistance. Sorry, don't understand this question. -- Richard Huxton Archonet Ltd