Scenario: In a social media platform, users can follow other users. However, a user cannot follow themselves. How would you enforce this constraint in the database?

  • Check Constraint
  • Foreign Key Constraint
  • Primary Key Constraint
  • Unique Constraint
To prevent a user from following themselves on a social media platform, you would use a Check Constraint. This constraint allows you to specify a condition, ensuring that the value in the follow relationship does not match the user's own ID.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *