Subject | Re: [firebird-support] Foreign Keys |
---|---|
Author | Ann W. Harrison |
Post date | 2004-12-20T22:16:35Z |
At 02:59 PM 12/20/2004, Ranando King wrote:
same way in the two cases.
are populated as part of the data storage operation. They're much more
effective for locating data than for returning data in a particular order.
the value is in the index, so the check is done when the value is
stored in the index. All the storing - data and index - is done in
buffers and the data is tagged with the transaction id so it can be
undone in the case of serious failures. If the index insert gets an
error, the transaction undoes its insert into data itself. Normally
none of the changes go to disk until it's all checked out, but it
can and the system is set up to bring back the incorrect entry for
removal. Other transactions don't see the new record because its
marked with the transaction id of an uncommitted transaction.
does allow duplicates as long as every active transaction sees only
one record with each version. Takes a bit of bookkeeping, but it
works.
referenced fields must be subject to a PRIMARY KEY or UNIQUE constraint.
Regards,
Ann
>Think of it like *before* and *after* checking on the data.Ummn, actually, no in firebird the checking is done exactly the
>
>Indexes check the data *after* the data is already in the table.
same way in the two cases.
>They sortFirebird indexes are b-tree variants, independent of the stored data, and
>the information so that you can retrieve the rows in some particular order,
>but they only work on rows currently written to the table.
are populated as part of the data storage operation. They're much more
effective for locating data than for returning data in a particular order.
>Constraints check the data *before they even reach the table. They check theActually, in Firebird the information necessary to accept or reject
>data that is about to be written to make sure that it's ok to write. If the
>data doesn't make sense to the constraint, then it would likely break an
>index so the constraint rejects the data.
the value is in the index, so the check is done when the value is
stored in the index. All the storing - data and index - is done in
buffers and the data is tagged with the transaction id so it can be
undone in the case of serious failures. If the index insert gets an
error, the transaction undoes its insert into data itself. Normally
none of the changes go to disk until it's all checked out, but it
can and the system is set up to bring back the incorrect entry for
removal. Other transactions don't see the new record because its
marked with the transaction id of an uncommitted transaction.
>Foreign keys are constraints. They check the data being written to the tableNo, not exactly. See above.
>to make sure that the data in some collection of fields matches the data in
>some other collection of fields in a different table, all before the data is
>written to the table.
> Primary key and Unique are constraints that make sureYes, and they do it through indexes.
>the data in that collection of fields is unique for each row in the data.
>The reason a Foreign Key must connect to a Primary key and not just anotherExcept that in a multi-versioning system like firebird the index
>index is because Primary keys are guaranteed to maintain referential
>integrity, that is, there's a 1-to-1 relationship between Primary key values
>and associated rows.
does allow duplicates as long as every active transaction sees only
one record with each version. Takes a bit of bookkeeping, but it
works.
>I'm not sure about this, but I think theNope. Either type of index is equally reliable.
>difference between a Primary key and a Unique Index is that the Primary key
>is the index that the database knows it can depend on for identifying
>records, hence it doesn't have to track an unpredictable number of column
>combinations just to know which record to grab when doing reference checks.
>It's about making the architecture more efficient and effective.It's about complying with the SQL standard which says that the
referenced fields must be subject to a PRIMARY KEY or UNIQUE constraint.
Regards,
Ann