I have the following entity:
class Terms {
//hash key
private String code;
private String region;
private String market;
private String brand;
private String productType
}
Which is persisted to Dynamo DB table. I need to implement a constraint that would restrict a possibility to create Terms with the same region, market, brand and productType
so that this combination of fields is unique. I'm new to DynamoDB and the first thing that comes to my mind is implementing this restriction on a application level e.g. implementing a service layer function that checks if Term
with given combination of field values region = X, market = Y, brand = U, productType = Z
already exists and in case if it exists throw an exception.
However, I wonder if there is a way to implement this restriction on a DynamoDB layer - is there a way to make this combination of fields unique on a table definition level?
Any help is appreciated,
Thanks,
Cheers