Skip to Content

Is it recommended to use foreign keys in HANA ?

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Mar 13, 2017 at 11:54 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 13, 2017 at 02:28 PM

    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.


    Add comment
    10|10000 characters needed characters exceeded