Board index » delphi » Paradox index files

Paradox index files

Hi!

    Just for curiosity: Why Delphi Paradox must have a primary index before
one can create a secondary index?  Is there any different on primary index
w.r.t secondary indexes in functionality aspect.  In some cases, if I want
only one non-unique index file, can I do that? (since primary index must be
unique).  Paradox always create 2 files for secondary indexes, i.e. *.x??
and *.y??, why need 2 files for each index key?

    Any enlightenment is greatly appreciate!

Teck Meng, Liaw.

 

Re:Paradox index files


Paradox "PX" files are the primary-index files.  They consist of a
B-tree whose leaf nodes point to the DB-file.

Secondary index files are built using a pair of files that basically
have the same relationship to one another as a DB and a PX.

The reason why the primary-key is required, though, is that the
secondary-index data contains, not a record-number, but a primary key
value.  So the computer uses the secondary index to locate the
primary-key value, and the primary-key to locate the record.  There is
also a "hint" field which suggests where the block in the DB-file might
be (potentially eliminating the primary-key lookup step), but it appears
to rarely be current or usable.

My recommendation as far as unique-indexes are concerned is...  don't
try to economize on indexes.  Let the primary-key be whatever is a
useful "best unique identifier."  Or if there is none, what-the-heck
make it a random number or string.  If there is another field that is
frequently-searched and must-be-unique, but it's not the "unique
identifier" that a human-being would think of in relation to these data,
then use a secondary-index for it but don't make it your primary.  The
key-designations need to "make sense" in the long run.

Quote
>Teck Meng, Liaw wrote:
>     Just for curiosity: Why Delphi Paradox must have a primary index before
> one can create a secondary index?  Is there any different on primary index
> w.r.t secondary indexes in functionality aspect.  In some cases, if I want
> only one non-unique index file, can I do that? (since primary index must be
> unique).  Paradox always create 2 files for secondary indexes, i.e. *.x??
> and *.y??, why need 2 files for each index key?

------------------------------------------------------------------
Sundial Services :: Scottsdale, AZ (USA) :: (480) 946-8259
mailto:i...@sundialservices.com  (PGP public key available.)
Quote
> Fast(!), automatic table-repair with two clicks of the mouse!
> ChimneySweep(R):  "Click click, it's fixed!" {tm}
> http://www.sundialservices.com/products/chimneysweep

Re:Paradox index files


You find some information in the helpfile with database desktop. Primary
indexes are mainly used to ensure referential integrity, avoiding duplicate
records. You wouldn't want to have 2 different customers with the same ID.
But you don't need a primary index, the only thing required is that primary
index fields are the first fields in the structure. You can choose to work
without a primary key for tables that contain duplicate entries, then you
create secondary indexes which are only used to present information in the
chosen order. Getting back on the customer example, your customer database
would need a primary key. A database with customer orders, linked to the
customer ID,  could go without a primary key. Making it primary on the
customer ID would only allow one order per customer.

--
Alex Haerens
AHA-design

alexhaerens_at_hotmail_dot_com

Teck Meng, Liaw <tml...@pc.jaring.my> schreef in berichtnieuws
8iggst$f1...@news6.jaring.my...
| Hi!
|
|     Just for curiosity: Why Delphi Paradox must have a primary index
before
| one can create a secondary index?  Is there any different on primary index
| w.r.t secondary indexes in functionality aspect.  In some cases, if I want
| only one non-unique index file, can I do that? (since primary index must
be
| unique).  Paradox always create 2 files for secondary indexes, i.e. *.x??
| and *.y??, why need 2 files for each index key?
|
|     Any enlightenment is greatly appreciate!
|
| Teck Meng, Liaw.
|
|

Re:Paradox index files


Quote
HAERENS wrote:

> You can choose to work
> without a primary key for tables that contain duplicate entries, then you
> create secondary indexes which are only used to present information in the
> chosen order.

No, BDE/Paradox database does not allow this. If you create secondary
indexes, you always must first have the primary index too. There was
some specific BDE error message if you try to use it in some other way,
I don't remember what that error was.

I don't know exact reason why it is this indexing designed this way.
I'll just accept it being so, and write my apps and indexes according
that rule.

Markku Nevalainen

Re:Paradox index files


Quote
"Markku Nevalainen" <m...@iki.fi> wrote in message

news:394D629C.6B38@iki.fi...

Quote
> HAERENS wrote:

> I don't know exact reason why it is this indexing designed this way.
> I'll just accept it being so, and write my apps and indexes according
> that rule.

I believe that the reason is that entries in Paradox secondary indexes
actually point back to the primary index which is then used to actually
locate records.

Other Threads