cancel
Showing results for 
Search instead for 
Did you mean: 

Is it recommended to use foreign keys in HANA ?

former_member208449
Active Participant

Could anyone please let me know if it is worthy to use foreign keys to maintain data integrity at the expense of performance in SAP HANA.

Accepted Solutions (1)

Accepted Solutions (1)

lbreddemann
Active Contributor

If you are asking this question, then the answer is likely: YES!
Do implement any measure that helps your data to be consistent.

Not using DB constraints puts the responsibility for ensuring data consistency to the application layer. That means you, the developer, has to write or use code that does these things.

Are you doing that? If so, what kind of consistency do you ensure? Avoiding duplicates? Avoiding false references through insert/update/deletes? Does your data model even allow for automatic consistency handling? Approaches like entity-value-store modelling decidedly don't allow for that.

Data consistency is never the question of performance. You don't want your wrong data to be processed faster. The results will still be wrong.

Answers (1)

Answers (1)

Hi Gowthami,

Foreign Keys are called Referential Constraints in SAP HANA. Maintaining Referential Constraints for a tables to check the data integrity depends on the requirement. if we are dealing with some transaction requirement and not focusing on just creating a datawarehouse, i would suggest to go for it.

Thanks