Exactly one payment reference (XOR check)

SQL Hard 8 views
Back to Questions

Problem Description

In Payments(payment_id, order_id, card_txn_id, upi_txn_id), a payment can be done either by card or by UPI. Enforce rule: exactly one of card_txn_id and upi_txn_id must be filled (not both, not none). Also keep each txn id unique.

Input Format

SQL DDL

Output Format

DDL statement(s)

Sample Test Case

Input:
Payments(payment_id, order_id, card_txn_id, upi_txn_id)
Output:
Constraints added

Constraints

Assume table exists

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev