I want to design an application for result computation.
First, I need to know how to store record in a MySQL database in such a way that students can have as many co
For completeness sake, not in a matter that this is a general recommended solution:
MySQL as of version 5.7.8 provides the the JSON datatype, which allows to store and retrieve objects and arrays in the JSON format.
This way, you can store entire objects and arrays into a field, as an array would look like:
['subject_1', 'subject_2', 'subject_3']
Especially beginners don't know this, and they reinvent the wheel by yet another comma-separated string implementation or using language-dependent serialization/deserialization approaches.
At least JSON is very commonly used and easily parsed as a data exchange format.
There are valid use cases for using storing arrays and objects inside a MySQL field, e.g. for speed optimization or when you have unknown or dynamic properties that you still want to save in a DB.
Yet as a rule of thumb, if you rely on storing objects and arrays into MySQL, then either your database design is most likely broken or you should rather use a document-based database like MongoDB.