Subject RE: [firebird-support] How are foreign keys implemented, cascade update performance
Author Dunbar, Norman
Morning Sqlsvr,

(I presume that's not your real name!)

>> One of my data models use natural keys that can change
>> overtime. How are foreign keys and cascades implemented in
>> the latest version of Firebird?
Much the same as in Oracle and other proper databases. The values you
put in the FK columns in the child table must match to the values in the
parent table.

>> Is it like in a REAL rdbms
You mean, in the same way that SQL Server isn't?
;-)

>> where the foreign key is actually a internal pointer to the
>> referenced table
I have never come across any database, at least that I can remember -
hierarchic or relational, which works in this fashion. Simply because
when you backup & restore the database, the internal pointers change and
become invalid as the rows are placed in different locations.


>> and cascades are "instant" no matter how
>> big the database is OR is it a fake dbms where the foreign
>> key is duplicated on all referencing tables and massive
>> cascades will cause all sorts of locks and crash the dbms?
Well, I work with terabyte Oracle databases on a daily basis and if I
wanted to, I could cascade a change and the database wouldn't crash, or
lock up. However, in our real world real databases (sorry, can't
resist!) we don't do that anyway. The default for a foreign key
constraint is not to cascade deletes and (under Oracle) cascading
updates are not allowed as an option. The other allowed cascade is to
set null.

Regarding lockups, if I remember correctly, SqlServer locks pages - even
on a SELECT - and then whole tables if too many pages are locked because
it has limited space in the lock table. Other (real) databases don't -
they lock at the row level and so have no need of a lock table.

Welcome to Firebird. Hopefully, you will soon begin to stop thinking in
terms of how SqlServer does things and find out how Firebird does them
better/differently/etc. A good place to start is with the online docs at
www.firebirdsql.org.


Cheers,
Norman.


Information in this message may be confidential and may be legally privileged. If you have received this message by mistake, please notify the sender immediately, delete it and do not copy it to anyone else. We have checked this email and its attachments for viruses. But you should still check any attachment before opening it. We may have to make this message and any reply to it public if asked to under the Freedom of Information Act, Data Protection Act or for litigation. Email messages and attachments sent to or from any Environment Agency address may also be accessed by someone other than the sender or recipient, for business purposes. If we have sent you information and you wish to use it please read our terms and conditions which you can get by calling us on 08708 506 506. Find out more about the Environment Agency at www.environment-agency.gov.uk

Information in this message may be confidential and may be legally privileged. If you have received this message by mistake, please notify the sender immediately, delete it and do not copy it to anyone else.

We have checked this email and its attachments for viruses. But you should still check any attachment before opening it.
We may have to make this message and any reply to it public if asked to under the Freedom of Information Act, Data Protection Act or for litigation. Email messages and attachments sent to or from any Environment Agency address may also be accessed by someone other than the sender or recipient, for business purposes.

If we have sent you information and you wish to use it please read our terms and conditions which you can get by calling us on 08708 506 506. Find out more about the Environment Agency at www.environment-agency.gov.uk