I want to use a SET datatype for my databse. So that a field of that type can contain one or more values from that data type.
But I have following two questions:
Q1. Is SET is correct to use as a datatype in a database? I think that its not supported by all the databases.
Q2. If SET is not a good option, then what can I use in place of SET?
You should use a table for this with a foreign key:
So for example, you’d have data like this:
as for the
So that a field of that type can contain one or more values from that data typeI would not recommend this. It is best practice to store only one value per “field”. Storing multiple values in a single field is against the principle of Database normalization and will result in issues when you try to pull particular items out of the “set”. It is best to split each value into its own row, which means changing your table design. Supply more information about the data you are trying to store and I can recommend a table structure for you.