X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 7AF1F9DCB7F; Sun, 19 Mar 2006 10:38:01 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 24896-08; Sun, 19 Mar 2006 10:38:05 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail.refusion.com (mail.refusion.com [213.144.155.20]) by postgresql.org (Postfix) with ESMTP id 34F089DCD22; Sun, 19 Mar 2006 10:37:57 -0400 (AST) Received: from iwing by mail.refusion.com (Cipher TLSv1:RC4-MD5:128) (MDaemon.PRO.v8.1.4.R) with ESMTP id md50000577461.msg; Sun, 19 Mar 2006 15:37:59 +0100 Message-ID: <058d01c64b62$b6323620$0201a8c0@iwing> From: To: "NbForYou" Cc: , References: Subject: Re: database model tshirt sizes Date: Sun, 19 Mar 2006 15:37:53 +0100 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.3790.1830 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.3790.1830 X-Authenticated-Sender: info@alternize.com X-Spam-Processed: mail.refusion.com, Sun, 19 Mar 2006 15:37:59 +0100 (not processed: message from trusted or authenticated source) X-MDRemoteIP: 212.254.173.184 X-Return-Path: me@alternize.com X-ClamAV: Pass X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=2.739 required=5 tests=[AWL=-0.684, DNS_FROM_RFC_DSN=2.872, NO_REAL_NAME=0.55, UNPARSEABLE_RELAY=0.001] X-Spam-Score: 2.739 X-Spam-Level: ** X-Archive-Number: 200603/317 X-Sequence-Number: 17754 another approach would be: table product: > productid int8 PK > productname charvar(255) table versions > productid int8 FK > versionid int8 PK > size > color > ... > quantity int4 an example would be then: table product: - productid: 123, productname: 'nice cotton t-shirt' - productid: 442, productname: 'another cotton t-shirt' table versions: - productid: 123, versionid: 1, color: 'black', size: 'all', quantity: 11 - productid: 442, versionid: 2, color: 'yellow', size: 'l', quantity: 1 - productid: 442, versionid: 2, color: 'yellow', size: 's', quantity: 4 - productid: 442, versionid: 2, color: 'red', size: 'xl', quantity: 9 - productid: 442, versionid: 2, color: 'blue', size: 's', quantity: 0 that way you can have more than 1 quantity / color / size combination per product and still have products that come in one size. so instead of only using a 2nd table for cases where more than one size is available, you would always use a 2nd table. this probably reduces your code complexity quite a bit and only needs 1 JOIN. - thomas ----- Original Message ----- From: "Patrick Hatcher" To: "NbForYou" Cc: ; Sent: Sunday, March 19, 2006 2:59 PM Subject: Re: [PERFORM] database model tshirt sizes > We have size and color in the product table itself. It is really an > attribute of the product. If you update the availability of the product > often, I would split out the quantity into a separate table so that you > can > truncate and update as needed. > > Patrick Hatcher > Development Manager Analytics/MIO > Macys.com > > > > "NbForYou" > .com> To > Sent by: > pgsql-performance cc > -owner@postgresql > .org Subject > [PERFORM] database model tshirt > sizes > 03/18/06 07:03 AM > > > > > > > > > > Hello, > > Does anybody know how to build a database model to include sizes for > rings, > tshirts, etc? > > > the current database is built like: > > table product > ========= > > productid int8 PK > productname charvar(255) > quantity int4 > > > what i want now is that WHEN (not all products have multiple sizes) there > are multiple sizes available. The sizes are stored into the database. I > was > wondering to include a extra table: > > table sizes: > ======== > productid int8 FK > size varchar(100) > > > but then i have a quantity problem. Because now not all size quantities > can > be stored into this table, because it allready exist in my product table. > > How do professionals do it? How do they make their model to include sizes > if any available? > > > ---------------------------(end of broadcast)--------------------------- > TIP 9: In versions below 8.0, the planner will ignore your desire to > choose an index scan if your joining column's datatypes do not > match >