Now, I have 200k objects in java, each of which have an unique ID. I will access them randomly later. So I want to save these objects into a database. Which kind of database should be a good choice? The relational database(MySQL) or some NoSQL database?
-
2Do you need to store relations between the objects or just reference the objects by id?maerics– maerics2013-02-05 21:10:59 +00:00Commented Feb 5, 2013 at 21:10
-
If you only want to access by id any NoSQL-DB can do this.MrSmith42– MrSmith422013-02-05 21:11:51 +00:00Commented Feb 5, 2013 at 21:11
-
2This depends a lot on your other requirements. If retrieval by a unique ID is all you need is a commonly overlooked "database" type called "plain files" :-)Sergey Kalinichenko– Sergey Kalinichenko2013-02-05 21:12:01 +00:00Commented Feb 5, 2013 at 21:12
-
What's about performance requirements? What's about data growing? What the others persistence requirement might you have?Taky– Taky2013-02-05 21:29:15 +00:00Commented Feb 5, 2013 at 21:29
-
My need is simple, just access the objects by id. The number of objects is at most 200k. BTW, I want to store these objects on disk, not only in RAM, so maybe Berkeley DB would not help. (Am I right?)Xing Shi– Xing Shi2013-02-06 00:32:30 +00:00Commented Feb 6, 2013 at 0:32
2 Answers
I remember once working on a project where someone suggested that the ORM layer was unnecessary and over complicated the whole design.
He proposed that binary serializations should be written to a database table using the Object Id/Hash code, and a blob for the serialized object.
The problem that was pointed out with that approach occurs when the structure of a serialized Class changes, then all of the previously serialized object instancess need to be migrated/evolved.
So beware of storing a binary/serialized representation of an object for a long period of time.