Composite Key on Outsystems

Marco Sacay
2 min readJan 7, 2022

“A composite key is made by the combination of two or more columns in a table that can be used to uniquely identify each row in the table when the columns are combined uniqueness of a row is guaranteed, but when it is taken individually it does not guarantee uniqueness, or it can also be understood as a primary key made by the combination of two or more attributes to uniquely identify every row in a table.”

Why and When do we need to use this?

Why?
To prevent having duplicate data.

When?
• Preventing a Candidate to apply on the same Job Position
• Preventing a Customer to rate on the same Item
• Preventing a Student to enroll on the same Subject

By practice, a table identifier / primary key from two tables were usually the one we combined. Imagine having these tables:

Candidate Table

Job Position Table

Job Application Table

where the candidate Arcom applied to Manager position thrice.

Now, how can we fix this problem?
Using Index on many-to-many relationship table Application

Whenever you attempt to save a combination of:
CandidateId + PositionId
twice on the same table.

**Unique: Set to Yes

a Database exception will arise.

--

--