Maybe Computed column
is the thing you are looking for.
Briefly, you can have another column, which is system generated based on your definition (here is the combination of each column of your composite key).
Then, when you query the table, you can query that Computed Column
.
For example, for a Charge: you have ChargeCode and ChargeAmount, and those two are the composite key. Then the Computed Column
will have the value (ChargeCode + ChargeAmount).
Charge example one: ChargeCode: A ChargeAmount: 100 (Composite key)
If you write a query as usual:
SELECT * FROM Table WHERE ChargeCode = 'A' AND ChargeAmount = '100'
If with Computed Column
: ComputedColumn_Key: A100 (notice the data type conversion here for string concatenation)
Then the query will be SELECT * FROM TABLE WHERE ComputedColumn_Key = 'A100'