pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Rich Shepard <rshepard@appl-ecosys.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: Refining query statement
Date: Thu, 17 Jan 2019 09:21:48 -0800
Message-ID: <7cbcfe0e-813e-b25e-f90e-dbf1e04f5076@aklaver.com> (raw)
In-Reply-To: <alpine.LNX.2.20.1901170857310.18965@salmo.appl-ecosys.com>
References: <alpine.LNX.2.20.1901150738320.5845@salmo.appl-ecosys.com>
	<9a5976c8-76da-f06d-9840-5dcf8723e38b@gmx.net>
	<alpine.LNX.2.20.1901170759560.13573@salmo.appl-ecosys.com>
	<CAKFQuwZFgogSc1Td0hXz7Jtzn3YvFisDEnPL6+3NLO1O7hsnkA@mail.gmail.com>
	<alpine.LNX.2.20.1901170842150.13573@salmo.appl-ecosys.com>
	<CAKFQuwaTZKOsMK6DpnuwJ4xbHAgiZqNsHBAHmqGED=g0=DW2kg@mail.gmail.com>
	<alpine.LNX.2.20.1901170857310.18965@salmo.appl-ecosys.com>

On 1/17/19 9:07 AM, Rich Shepard wrote:
> On Thu, 17 Jan 2019, David G. Johnston wrote:
> 
>> Yes...though now it just sounds like a flawed data model.
> 
> David,
> 
>    This is what I thought.
> 
>> How stuck are you in that regard? Those "future" contacts should have 
>> their
>> own records and not be derived via an optional field on an existing
>> record.
> 
>    My goal is to make a functioning business tracking application for my
> consulting services. Almost all my prior postgres databases hold
> environmental data for statistical and spatio-temporal analyses so 
> writing a
> business application is a new experience for me and I want to get it
> correct.
> 
>> Put differently, how do you know which activities are completed and
>> which are not?
> 
>    The direct answer is that a completed activity has a row with either a
> future next-activity date or a null (which is the case when the status of
> that organization or contact is 'no further contact'.)

To be clear the next-activity date = next_contact in the database, correct?

NULL basically means unknown, so having it stand for something is a bit 
of a stretch. Seems to me a boolean field of name active to denote 
contacts you need to keep up with is in order. Then make the 
next_contact field NOT NULL and replace the current NULL values with 
'infinity':

https://www.postgresql.org/docs/10/datatype-datetime.html

8.5.1.4. Special Values


As to current situation:

1) Use my previous suggestion.

or

2) WHERE COALESCE(next_contact, 'infinity') BETWEEN '01/01/2019'::date 
AND 'today'::date

https://www.postgresql.org/docs/10/functions-conditional.html#FUNCTIONS-COALESCE-NVL-IFNULL

> 
>    I should rename the Contacts table as People and the Activities table as
> Contacts. The original names came from a sales management system I used 
> as a
> design guide, but they're probably confusing to others as well as to me. 
> :-)
> 
>    I can provide my current schema (eight tables) to the list (perhaps 
> as an
> attachment), an individual, or put in on a cloud site and pass the URL.
> 
> Thanks,
> 
> Rich
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com




view thread (32+ messages)  latest in thread

Message-ID: <7cbcfe0e-813e-b25e-f90e-dbf1e04f5076@aklaver.com>
Permalink:  ../7cbcfe0e-813e-b25e-f90e-dbf1e04f5076@aklaver.com/
Also on:    postgresql.org/message-id/7cbcfe0e-813e-b25e-f90e-dbf1e04f5076@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, rshepard@appl-ecosys.com
  Subject: Re: Refining query statement
  In-Reply-To: <7cbcfe0e-813e-b25e-f90e-dbf1e04f5076@aklaver.com>
  References: <alpine.LNX.2.20.1901150738320.5845@salmo.appl-ecosys.com> <9a5976c8-76da-f06d-9840-5dcf8723e38b@gmx.net> <alpine.LNX.2.20.1901170759560.13573@salmo.appl-ecosys.com> <CAKFQuwZFgogSc1Td0hXz7Jtzn3YvFisDEnPL6+3NLO1O7hsnkA@mail.gmail.com> <alpine.LNX.2.20.1901170842150.13573@salmo.appl-ecosys.com> <CAKFQuwaTZKOsMK6DpnuwJ4xbHAgiZqNsHBAHmqGED=g0=DW2kg@mail.gmail.com> <alpine.LNX.2.20.1901170857310.18965@salmo.appl-ecosys.com> <7cbcfe0e-813e-b25e-f90e-dbf1e04f5076@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