Creating a Table in SQL

Hypothetical situation. You create a column in SQL where the datatype is TEXT. However you wish that said column be limited to only certain text options in the same manner as a multiple choice question to prevent users from entering meaningless text into the column. Is there a way to do this?

there isn’t a single straight forward answer to this question, if you want to enforce this at database level there is enum:

or enforce this logic at application level, depending on what it is exactly you are after.

Thank you. I have only been on codeacademy for three days so forgive me when I ask…

Is the difference between application level vs databaselevel that at application level the program will have this restriction for every database it uses vs database level it is restricted more per the application and database you are using.

If this is correct, I can see a desire to restrict at database level but at application level what would be the point?

there are some good answers:

if you enforce business logic on application level, other developers might not be aware of it and abuse the database, but enforcing on database level is less flexible

there are a lot of pros and cons to consider to which approach you want to use, and maybe you want to enforce the logic at both levels