Prev | Current Page 427 | Next

Carl Reynolds and Paul Tymann

"Schaum's Outline of Principles of Computer Science"


5 Updating the primary key in the parent table is permitted only if there are no child rows.
6 Updating the foreign key in a child row is allowed only if the new value also exists in the parent table.
As a database designer, one can count on the DBMS to enforce these basic constraints that are essential if
relationships between entities are to be maintained satisfactorily. Many times additional constraints must be
maintained in order to satisfy the business rules that must be enforced by the database.
For instance, it is sometimes true that business rules require at least one child row when a parent row is first
inserted. Suppose that one is running a database for a sailing regatta. Each boat has a skipper and crew, and the
relationship between boat and crew is 1:N (1 boat:many crew). The boat is the parent row to the crew child rows.
A data rule could be that a boat may not be added to the database unless at least one sailor immediately is registered
as crew (after all, there??™s no need to store information about boats that aren??™t racing). Such a constraint would
not be naturally enforced by any of the default referential integrity constraints, but one could create a trigger
that would automatically prompt for and add a sailor??™s name when a new boat is inserted.


Pages:
415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439
e-lady traktorki ogrodowe need cash fast bad credit prace wysokościowe Program TV