andandandand
andandandand

Reputation: 22270

Triggers: How can I make this integrity restriction in Oracle?

I want to make it so each time a register of type Pilot or type Flight_Attendant is added, a register of type Crew is added. I'm working on Oracle's SQL Developer on top of 10g, should I use a trigger?

Upvotes: 0

Views: 90

Answers (2)

Ken Downs
Ken Downs

Reputation: 4827

Personally I prefer triggers, because it does not require changes to app code that may be inserting to the table. Once the trigger is on there, a BEFORE INSERT, then the new rows in CREW type appears magically with no change to code.

Upvotes: 0

Thomas Jones-Low
Thomas Jones-Low

Reputation: 7161

That would be one way of doing what you want. Another it so write a stored procedure to you need to call. The procedure would perform the registration of the Pilot or Flight_attendant and type Crew.

For example, I would have a procedure REGISTER_CREW which takes a crew_type parameter (along with other details) and have that correctly register the Crew type, and the pilot and flight attendant. That way, if there are other rules they can all be added in the same place.

Upvotes: 4

Related Questions