Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fk9wB-0000MV-Sj for pgsql-general@arkaria.postgresql.org; Mon, 30 Jul 2018 15:18:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fk9w8-00072g-6Q for pgsql-general@arkaria.postgresql.org; Mon, 30 Jul 2018 15:18:16 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fk9w7-00072Z-Qs for pgsql-general@lists.postgresql.org; Mon, 30 Jul 2018 15:18:15 +0000 Received: from mail-oi0-x242.google.com ([2607:f8b0:4003:c06::242]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fk9w5-0002LM-Do for pgsql-general@lists.postgresql.org; Mon, 30 Jul 2018 15:18:14 +0000 Received: by mail-oi0-x242.google.com with SMTP id 13-v6so21912524ois.1 for ; Mon, 30 Jul 2018 08:18:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=bLOOdmTi8uNQ+LlqaQCPdNrA2njKF2M3bur1L1G1EIQ=; b=Iy9xa9iPaB2ZpVSQUHvuznU29UiL+T581zGQzupFVrxv9i8DJxGaK76cpWV3x9x4n1 0AKGtVixSyjhFXny3srhKnrZCAapaOXEAf2aXo0W6vzSDKkRW4w1hCs2DNY++CbQYgYF DVziK36gmixXjs2Ni6qv3sJGqzoFmPD9+d/163TpA+WhtuXlhYrdpRZGfjl6dmLgSuOh 0JcXWd/ZkhIgw2StKZfOrGpMIka0L/2Ko9rRlpOxP0IPVi1c7YnrGc9aZAKBoFAnskuA 4J9UA8CD0wrkMo9N65x9RMKGW1OHgdMLvtEpAUuaFxIyieVZnwivgf9ywAHDjinGIanF 6tfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=bLOOdmTi8uNQ+LlqaQCPdNrA2njKF2M3bur1L1G1EIQ=; b=DWQxYusuMbmzbVXwo9XQ+M4PkTiouMujhswrwbct4zSKax8Fysei2id9j4tuuvujZ5 BhPfy9RVxxmd8cOxzRIBAID86hny09nPr9dck5aBVDnLyKpYFVuTLe7VnS9+luVogMDR Nt98E0rZOfjMNwW12pV74BBM9CLXb7NP8/mGcqx3icvaPbi+xYpmfNR9AxihIaWmfTZZ PoQQIryROzD2jocxZigHGThiK4iK3SrXeSWf5e4HBXUozAERAxOInzTUlDDI4FURif7q GnvPXFUS7ZG+C7lMARAdlmojFTlpX9RLO5GvCCC6X+ThlS7/KiNH/nzuqiRzRW8L7rvQ cAyw== X-Gm-Message-State: AOUpUlE4OoOTCPEvXEQu7DPQNVFdvaR1R3cXmYYzELDqrB448ikyWZnW Ls+WLbLFlVLGECdejrfPwLjwjFAw X-Google-Smtp-Source: AAOMgpcPK/Il4ZBK5mK95q6bV0hhdzjz2nF5KBCpxHHHeYIz2Oc0TKODByk3Oq3dh0Q+083ZU5H+YA== X-Received: by 2002:aca:3e03:: with SMTP id l3-v6mr1186390oia.54.1532963892408; Mon, 30 Jul 2018 08:18:12 -0700 (PDT) Received: from [192.168.1.10] (ip70-171-116-89.no.no.cox.net. [70.171.116.89]) by smtp.googlemail.com with ESMTPSA id r187-v6sm7970709oie.43.2018.07.30.08.18.10 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Jul 2018 08:18:11 -0700 (PDT) Subject: Re: Design of a database table To: pgsql-general@lists.postgresql.org References: From: Ron Message-ID: <8da832f3-f1f6-2723-b755-ba54a6943e36@gmail.com> Date: Mon, 30 Jul 2018 10:18:10 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 07/30/2018 09:37 AM, hmidi slim wrote: > I'm trying to design a database table. First of all there are two > alternatives: > 1-) Divide the table into two tables and make a join. > 2-) Design a single table. > > 1rst alternative: > Create table data_periods( > id serial primary key not null, > period daterange, > project_id integer > ) > > create table data_periods_info( > id serial primary key not null, > data_periods_id integer, > data_sub_periods daterange, > stock1 integer, > stock2 integer, > CONSTRAINT data_periods_allotment_id_fkey FOREIGN KEY (data_periods_id) >         REFERENCES data_periods (id) MATCH SIMPLE >         ON UPDATE NO ACTION >         ON DELETE NO ACTION > ) Are you absolutely 100% positive that there will NEVER be more than two stock numbers?  (People say "yes" to this kind of question all the time and then discover that they need more stock numbers when the business changes.) -- Angular momentum makes the world go 'round.