declaring constraint to consider prog logic

Posted by shantanuo on Stack Overflow See other posts from Stack Overflow or by shantanuo
Published on 2010-03-05T11:41:41Z Indexed on 2010/04/16 7:03 UTC
Read the original article Hit count: 287

Filed under:

I can open a trip only once but can close it multiple times. I can not declare the Trip_no + status as primary key since there can be multiple entries while closing the trip. Is there any way that will assure me that a trip number is opened only once?

For e.g. there should not be the second row with "Open" status for trip No. 3 since it is already there in the following table.

Trip No | Status
1     Open
1     Close
1     Close
2     Open
2     Close
3     Open
3     Close
3     Close
3     Close
3     Close

© Stack Overflow or respective owner

Related posts about mysql