1

I am designing a database for a custom software application. The part I am focused on now is the ability to add custom questions to ask users.

I want to ensure that each user can only answer a question once. In this case, a user is a 'Provider'. How do I ensure each user only answers a question once?

database mockup

markp-fuso
2,6041 gold badge10 silver badges19 bronze badges
asked Sep 11, 2017 at 18:27
0

1 Answer 1

1

A unique constraint on Answers (questionid, providerid) was needed, as suggested by Balazs Papp.

As explicitly pointed out by Andriy M this should be a composite key.

I had to look up composite keys, as I was unfamiliar. Thanks so much to everyone for helping and responding so quickly.

Paul White
95.4k30 gold badges440 silver badges689 bronze badges
answered Sep 11, 2017 at 20:19

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.