Subject | Using COMPUTED fields to provide lookup results and allow backup/restore |
---|---|
Author | Raymond Kennington |
Post date | 2003-07-15T16:54:16Z |
Given the following:
CREATE TABLE Zip:
ID INTEGER
City VARCHAR(n)
State VARCHAR(n)
Zip VARCHAR(n)
and a table of names and addresses with a lookup into the Zip table:
CREATE TABLE Person
FirstName VARCHAR(50)
...
ZipID INTEGER
City COMPUTED BY ((SELECT Zip.City FROM Zip WHERE Zip.ID =
Person.ZipID))
The Person table cannot be created before the Zip table, as it refers
to the Zip table in the COMPUTED field.
Since there is no guarantee of the creation order of these two tables
during gbak/restore, how can this type of COMPUTED field be used?
Why is it permitted to be done if it is not possible to backup and
restore the database?
Would it make a different if instead of defining it in the CREATE of
the table it were defined in an ALTER statement?
ALTER TABLE Person
ADD
City COMPUTED BY ((SELECT Zip.City FROM Zip WHERE Zip.ID =
Person.ZipID))
Are ALTER TABLE statements restored after all tables have been
created?
--
Raymond Kennington
Programming Solutions
CREATE TABLE Zip:
ID INTEGER
City VARCHAR(n)
State VARCHAR(n)
Zip VARCHAR(n)
and a table of names and addresses with a lookup into the Zip table:
CREATE TABLE Person
FirstName VARCHAR(50)
...
ZipID INTEGER
City COMPUTED BY ((SELECT Zip.City FROM Zip WHERE Zip.ID =
Person.ZipID))
The Person table cannot be created before the Zip table, as it refers
to the Zip table in the COMPUTED field.
Since there is no guarantee of the creation order of these two tables
during gbak/restore, how can this type of COMPUTED field be used?
Why is it permitted to be done if it is not possible to backup and
restore the database?
Would it make a different if instead of defining it in the CREATE of
the table it were defined in an ALTER statement?
ALTER TABLE Person
ADD
City COMPUTED BY ((SELECT Zip.City FROM Zip WHERE Zip.ID =
Person.ZipID))
Are ALTER TABLE statements restored after all tables have been
created?
--
Raymond Kennington
Programming Solutions