Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When using an object database, how do you handle significant changes to your object model?

If you use an object database, what happens when you need to change the structure of your object model?

For instance, I'm playing around with the Google App Engine. While I'm developing my app, I've realized that in some cases, I mis-named a class, and I want to change the name. And I have two classes that I think I need to consolidate.

However,I don't think I can, because the name of the class in intuitively tied into the datastore, and there is actual data stored under those class names.

I suppose the good thing about the "old way" of abstracting the object model from the data storage is that the data storage doesn't know anything about the object model --it's just data. So, you can change your object model and just load the data out of the datastore differently.

So, in general, when using a datastore which is intimate with your data model...how do you change things around?

like image 498
Deane Avatar asked Apr 05 '11 17:04

Deane


People also ask

What are the four 4 significant objects on making a database?

Databases in Access are composed of four objects: tables, queries, forms, and reports. Together, these objects allow you to enter, store, analyze, and compile your data however you want.

What is object relational model what is its significance?

An Object relational model is a combination of a Object oriented database model and a Relational database model. So, it supports objects, classes, inheritance etc. just like Object Oriented models and has support for data types, tabular structures etc. like Relational data model.

Which is a programming strategy to map object with the data structure in the database?

Object–relational mapping (ORM, O/RM, and O/R mapping tool) in computer science is a programming technique for converting data between type systems using object-oriented programming languages. This creates, in effect, a "virtual object database" that can be used from within the programming language.

What is object model in database?

An object data model is a data model based on object-oriented programming, associating methods (procedures) with objects that can benefit from class hierarchies. Thus, “objects” are levels of abstraction that include attributes and behavior.


2 Answers

If it's just class naming you're concerned about, you can change the class name without changing the kind (the identifier that is used in the datastore):

class Foo(db.Model):
  @classmethod
  def kind(cls):
    return 'Bar'

If you want to rename your class, just implement the kind() method as above, and have it return the old kind name.

If you need to make changes to the actual representation of data in the datastore, you'll have to run a mapreduce to update the old data.

like image 150
Nick Johnson Avatar answered Nov 02 '22 10:11

Nick Johnson


The same way you do it in relational databases, except without a nice simple SQL script: http://code.google.com/appengine/articles/update_schema.html

Also, just like the old days, objects without properties don't automatically get defaults and properties that don't exist in the schema still hang around as phantoms in the objects.

To rename a property, I expect you can remove the old property (the phantom hangs around) add the new name, populate the data with a copy from the old (phantom) property. The re-written object will only have the new property

like image 29
Cade Roux Avatar answered Nov 02 '22 10:11

Cade Roux