This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I have a set of objects that hold information about articles, for example the article's title, its author and its subject(s). The subjects are String values stored in an ArrayList. The number of subjects is different for almost every article. I want to store the values of those objects in a database (currently i use MySQL) so i can search in them. After a search, the returned values are going to be recreated into an object so i can use it the way i want.
So, i thought something like this:
In the subject column, if there are more than one subjects i will generate the string that will be stored, using comma separation like "Java, Databases, Programming" so upon retrieval i will generate again the ArrayList. Do you think this is the correct solution? Do you have any other suggestions?
PS: This is just a small example of the actual table so don't mind about primary keys, IDs, etc.
George Goubak wrote: i will generate the string that will be stored, using comma separation like "Java, Databases, Programming" so upon retrieval i will generate again the ArrayList. Do you think this is the correct solution? Do you have any other suggestions?
I wouldn't do this as it would prevent you from searching by subject.
Rather I would create another table called subject_article_relationship (or the like.) It would just contain an article_id and subject. That way you can represent multiple subjects in tabular form.