Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Triggers

Author  Topic 

poser
Posting Yak Master

124 Posts

Posted - 2006-09-20 : 19:03:09
Hello all,
I have questions and need help with the writing triggers.

I have two tables

Reservations
Guest TableID Menu
1 5 4
2 6 3
3 7 2
4 5 3

Tables
TableID Seats Max
1 2 5
2 4 5
3 2 5
4 5 10
5 2 5
6 3 5
7 7 10
8 2 4


anytime the Reservations.Tableid is deleted\Inserted\Updated I want to reflect this in the tables column.

So if guest 1 changed to tableid 7
It would reflect in Tables TableID 7 Seats would increase to 8
and Table TableID 5 would decrease to 1


Results would look like this:

Reservations
Guest TableID Menu
1 7 4
2 6 3
3 7 2
4 5 3

Tables
TableID Seats Max
1 2 5
2 4 5
3 2 5
4 5 10
5 1 5
6 3 5
7 8 10
8 2 4


would a trigger work best for this?
Maybe I'm getting too complicated for me.
Thanks for your help.
r/
P

timmy
Master Smack Fu Yak Hacker

1242 Posts

Posted - 2006-09-20 : 19:22:00
Nope - a better design will help you better here.

Your 'Tables' table should not have the 'Seats' column. This is dynamic and should be derived from the 'Reservations' table.

Go to Top of Page
   

- Advertisement -