Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Putting Serializable Classes into SQL?

Here's the situation. I have a bunch of objects that implement Serializable that I want to store in a SQL database. I have two questions

  1. Is there a way to serialize the object directly into the database
  2. Is that the best way to do it or should I
    1. Write the object out to a formatting String and put it in the database that way and then parse it back out
    2. Write each member to the database with a field that is unique to each object
like image 549
CaseyB Avatar asked Jun 16 '26 15:06

CaseyB


1 Answers

Its generally not a good idea to try and put any sort of object (serialized/deliminated) in your SQL because modifying them is always a bitch.

It sounds like you're on the right track with idea 2. Is this a one-to-many situation? (because then a xref would obviously be the right answer) or even a foreign key would be better. cheers.

like image 60
Jason Avatar answered Jun 18 '26 05:06

Jason



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!