This is often situation, but here is latest example:
Companies have various contact data (addresses, phone numbers, e-mails…) when they make job ad, they have checkboxes where they choose how they want to be contacted. It is basically descriptive data. User when reading an ad sees something like ‘You can apply by mail, in person…’, except if it’s ‘through web portal’ or ‘by e-mail’ because then appropriate buttons should appear. These options are stored in database, and client (owner of the site, not company making an ad) can change them (e.g. they can add ‘by telepathy’ or whatever), yet if they tamper with ‘e-mail’ and ‘web-portal’ options, they screw their web site.
So how should I handle data where everything behaves same way except ‘this thing’ that behaves this way, and ‘that thing’ that behaves some other way, and data itself is live should be editable by client.
You’ve tagged your question as ‘language-agnostic’, and not all languages cleanly support polymorphism, but that’s the way I would approach this.
Each option has some type, and different types require different properties to be set. However, every type supports some sort of ‘render’ method that can display the contact method as needed. Since the properties (phone number, or web address, etc.) are type-specific, you can validate the administrator’s input when creating these ‘objects’, to make sure that the necessary data is provided and valid. Since you implement the render method, rather than spitting out HTML provided by a user, you can ensure that the rendered page is correct. It’s less flexible, but safer and more user friendly.
In the database, you can have one sparsely populated table that holds data for all types of contacts, or a ‘parent’ table with common properties and sub-tables with type-specific properties. It depends on how many types you have and how different they are. In either case, you would have some sort of type indicator, so that you know the type of object to which the data should be be bound.