X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A67865E46D2 for ; Thu, 12 Aug 2004 17:11:28 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 43016-03 for ; Thu, 12 Aug 2004 20:11:25 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 63E1C5E37CC for ; Thu, 12 Aug 2004 17:11:23 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id i7CKBMiG043733 for ; Thu, 12 Aug 2004 20:11:22 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i7CJj0AW033609 for pgsql-sql@postgresql.org; Thu, 12 Aug 2004 19:45:00 GMT From: jcelko212@earthlink.net (--CELKO--) X-Newsgroups: comp.databases.postgresql.sql Subject: Re: Suggestions on storing re-occurring calendar events Date: 12 Aug 2004 12:45:01 -0700 Organization: http://groups.google.com Lines: 30 Message-ID: <18c7b3c2.0408121145.2a035b1f@posting.google.com> References: <27c475ec04080907562c370b3a@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Complaints-To: groups-abuse@google.com To: pgsql-sql@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.9 tagged_above=0.0 required=5.0 tests=FROM_ENDS_IN_NUMS X-Spam-Level: X-Archive-Number: 200408/133 X-Sequence-Number: 18630 >> I'd like to figure out a way to add simple re-occurrances of events. I can think of two ways, [a] Using application logic, create a finite number of future occurrences --for example, for 10 occurrences, 10 entries into ftr_cal_events will be created. This seems like an ugly hack. << No, not really; go with [a]. This is SQL and it is designed for tables, not computations. For example, to pull out one I recently looked at, say I am setting out a payment plan. I generate a list of 100 payments made up of (client_id, payment_due_date, payment_due_amt, actual_payment) rows by some simple temporal math -- "give me $100 every 30 days!" Now I go to my Calendar table (lots of posting about why you need a Calendar table on Google). If a payment date falls on a holiday, I move it up to the next business day. I do not try to calculate Easter or Chinese News Years on the fly; I cannot calculate somethings like national emergencies and disasters. I can print the whole plan out for the guy; his future actual payments are defaulted zero, and I can easily recompute his future amounts due from his past payments. Other advantages: portable data instead of proprietary temporal computations. The rows in this payment schedule are pretty small, so it runs fast. You can immediately see conflicts by having all the enterprised events in the same place and in the same format. For example, summing up the expected payements for any given date is trivial with a full payment schedule on everyone.