pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: hmidi slim <hmidi.slim2@gmail.com>
Cc: pgsql-general@postgresql.org
Subject: Re: Design of a database table
Date: Tue, 31 Jul 2018 06:53:32 -0700
Message-ID: <70eaca06-ab66-0c34-1da4-cf9233d03134@aklaver.com> (raw)
In-Reply-To: <CAMsqVxu3vj-fiHHoqbJsmHQQsM4-ARfcQDi9xSD9fHBWCgmm5Q@mail.gmail.com>
References: <CAMsqVxuQXUDU2LkXz1u620GCQL1QZddjN_hSuv1_2KETX0jnJA@mail.gmail.com>
	<c1115541-98bb-380b-520f-2124e9381333@aklaver.com>
	<CAMsqVxu3vj-fiHHoqbJsmHQQsM4-ARfcQDi9xSD9fHBWCgmm5Q@mail.gmail.com>

On 07/30/2018 11:40 PM, hmidi slim wrote:
> Actually, the data_periods contains a complete range such as 
> [2018-09-01,2018-09-30] and data_sub_periods contains sub periods 
> contained in this period like:
> [2018-09-05, 2018-09-07]
> [2018-09-09, 2018-09-11]
> [2018-09-12, 2018-09-19]
> 
> I make two conditions in order to fetch first if the period 
> [2018-09-01,2018-09-30] contained in the first table.If it exists I will 
> return the sub periods that overlaps the given period
> where data_periods.period && '[2018-09-01,2018-09-30]'::daterange
> and data_sub_periodsĀ  && '[2018-09-01,2018-09-30] '::daterange
> 

If data_sub_periods are actually sub periods of period then you should 
need only search for the period [2018-09-01,2018-09-30] and join 
data_periods_info to period on period.id = 
data_periods_info.data_periods_id.


-- 
Adrian Klaver
adrian.klaver@aklaver.com




view thread (5+ messages)

Message-ID: <70eaca06-ab66-0c34-1da4-cf9233d03134@aklaver.com>
Permalink:  ../70eaca06-ab66-0c34-1da4-cf9233d03134@aklaver.com/
Also on:    postgresql.org/message-id/70eaca06-ab66-0c34-1da4-cf9233d03134@aklaver.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, hmidi.slim2@gmail.com
  Subject: Re: Design of a database table
  In-Reply-To: <70eaca06-ab66-0c34-1da4-cf9233d03134@aklaver.com>
  References: <CAMsqVxuQXUDU2LkXz1u620GCQL1QZddjN_hSuv1_2KETX0jnJA@mail.gmail.com> <c1115541-98bb-380b-520f-2124e9381333@aklaver.com> <CAMsqVxu3vj-fiHHoqbJsmHQQsM4-ARfcQDi9xSD9fHBWCgmm5Q@mail.gmail.com> <70eaca06-ab66-0c34-1da4-cf9233d03134@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox