Re: pervasiveness of surrogate (also called synthetic) keys - Mailing list pgsql-general

From Misa Simic
Subject Re: pervasiveness of surrogate (also called synthetic) keys
Date
Msg-id BANLkTinF0M9u_NojtRt0G98wiKhWT36v3w@mail.gmail.com
Whole thread Raw
In response to Re: pervasiveness of surrogate (also called synthetic) keys  (Merlin Moncure <mmoncure@gmail.com>)
Responses Re: pervasiveness of surrogate (also called synthetic) keys  ("David Johnston" <polobo@yahoo.com>)
Re: pervasiveness of surrogate (also called synthetic) keys  (Merlin Moncure <mmoncure@gmail.com>)
List pgsql-general


2011/5/4 Merlin Moncure <mmoncure@gmail.com>
Most of the old school accounting systems maintained an invoice line number.

> Invoice Line
>     -Invoice Number
>     -LineNo
>     -ItemID
>     -qty
>     -Price

The line number started from 1 (the first line on the invoice) on
every unique invoice.  This has the added benefit of allowing the
primary key index (invoice_no, line_no) allowing you to pull up the
invoice line records in correct order without requiring an extra sort
and, if you don't need any fields from the invoice, a join.

Compare the two queries pulling up invoice lines over a range of
invoice numbers.

merlin


Thanks, merlin,

And in that case, what is "Natural" in LineNo? I would say, with adding LineNo we are creating syntethic/surrogate Key (just instead of 1 surrogate column - it will be Compound key with more columns...)? The same is with all other tables what are "parts" of an Entity, Serial Numbers, Accounting Distribution produced by Invoice...etc etc...

 



pgsql-general by date:

Previous
From: "Dickson S. Guedes"
Date:
Subject: Re: postgresql not updating the sequence
Next
From: "David Johnston"
Date:
Subject: Re: pervasiveness of surrogate (also called synthetic) keys