Team Fly 

Page 81

  4     promo_subcategory,
  5     promo_subcategory_id,
  6     promo_category,
  7     promo_category_id,
  8     promo_cost,
  9     promo_begin_date,
 10     promo_end_date,
 11     promo_total,
 12     promo_total_id)
 13  values
 14    (36,
 15     'Thanksgiving Sale',
 16     'Newspaper',
 17     28,
 18     'ad news',
 19     4,
 20     250,
 21     '23-NOV-03',
 22     '27-NOV-03',
 23     'Promotion Total',
 24     5);
insert into promotions
*
ERROR at line 1:
ORA-00001: unique constraint (SH.PROMO_PK) violated

Since the value 36 already existed for promo_id, the unique constraint was violated when we tried to insert another row in the table with the same value. This constraint preserved the integrity of the data by enforcing the business rule that every promotion must be identified uniquely.

Linkage to Entity Models

Many organizations have complex databases and as a result, they use entity models to document each system's database objects and constraints. These models of the organizations database schemas graphically represent the relationships between objects.

The function of database design could be the responsibility of the developer, DBA or a database designer. Among other uses, entity-modeling software allows the database designer to graphically define and link tables to each other. The result is a data model with tables, columns, primary keys, and foreign keys. Throughout this chapter, we have issued DDL to create tables. Typically, entity-modeling software will generate the DDL in a script that can be executed against the database. This makes the job of defining and maintaining database objects and their associated constraints and relationships with each other a lot easier.

Team Fly 
0100