We have a table:
message (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`subject` VARCHAR(255) NOT NULL DEFAULT '',
`message` TEXT NOT NULL,
`attachment` VARCHAR(255) NULL DEFAULT NULL,
`new` TINYINT(4) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
)
Now we need to have multiple attachments.
Currently only one attachment link is being saved. A solution might be to add another foreign key table or use comma separated values in column. But we need a better solution for this which can use old system alongwith new, without much alteration. Any suggestions?
As @BurhanKhalid says, any solution to this will require changes in your application. You should just to do it right and normalize your data with a separate
attachmentstable with a foreign key. To support legacy app versions, leave theattachmentcolumn in the original table alone, then create a trigger to fill it with the first attachment link that gets added to the new, normalized table. Long-term, you want to fix your legacy app to use the new table and then deprecate the old column.