db4o Developer Community
Developer Community db4o open source object database, native to Java and .NET
Register   |  Login
  Search
  • Forums
  • Documentation
  • Resources
  • Downloads
  • Blogs
  • About
Unanswered Active Topics Forums
Forums > English Forums > db4o User Forum
Unique ID/Unique Constraint question
Last Post 17 Oct 2006 06:02 PM by dougleeper. 3 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
dougleeper
New Member
New Member
dougleeper

--
15 Oct 2006 06:23 PM  

I have a question on how one may be able to solve my perceived situation.  I believe it boils down to a unique id/unique constraint issue but need validation.  First a list background on my situation.

I  have web based solution that stores its data in a RDBMS.  I also have Mobile devices that connect via web services to up/download data and store locally (currently XML files would like to move to DB40).  The RDBMS tables create identities for each row in each table.  Note: I am using table per object strategy (hibernate). 

The problem I see is when I download data from the server to the mobile device.  Not sure how I would be able to ensure uniqueness as DB40 and RDBMS are two different paradigms (UUID vs Identity columns).  For instance I have Object Foo with identity 1 and an object Bar with identity 1.  The Identity would not work in DB40 if I understand correctly as the OODBMS has unique identifier for all objects stored.

In addition, it appears that if I download Object Foo with the same Identity more than once and store in DB40, there would be that many instances as I had downloaded it.  How can I ensure that there would be one and only one instance of Foo with Identify of 1.

Can anyone point me in the direction on how to solve this?  Has anyone else experienced this situation before?  Any hints/tips or just a plain can't be done?

Thanks in advance,

- Doug 

dougleeper
New Member
New Member
dougleeper

--
15 Oct 2006 09:19 PM  

I think I may have found a solution that would work with my situation.

Some additional information that needs to be communicated about my domain model and its use on the mobile device.

For the mobile device, db4o is to be used as a storage mechanism only. The master DB is the RDBMS on the server.  Db4o is replacing XML files on the mobile device as it is more open to domain changes.  Identities are created/maintained at the Server and not at the mobile device.

For the domain model, I will attempt to explain in a simplified form.  The true domain model is a little more complex than the following. The total number of "top-level domain" classes will be less than 10 and total number of all classes will be around 50.  So we do have some deep nested object graphs.

For 3 domain objects Foo, Bar, and Baz.  Foo contains a Bar and Baz reference. All are "top-level business domain objects".  They all are retrieved directly from the DB and displayed separately.  However, in the case of Foo's references to Bar and Baz, it maintains a relational Identity, i.e. barId and bazId, and the actual instances are (C#) [NonSerialized]/ (Java)transient. To obtain these instances, they are not retrieved from Foo but from the DB with Foo's referenced identity values.  (Note: in some cases, the expected instances may not exist which is a possibility and not an error due to the distributed and disconnected nature of the application).

To solve updating, I am planning on attempting the following. 

When updates do occur (retrieve via web services and store in local db), the bind() method will be utilized were possible. This applies nicely for single objects with only primitive data types.   However, one needs to careful with object graphs...either deep nested or collections of objects as duplicates (via Identity) can occur.  To combat this issue, I will purge() with cascades the "top-level domain object" then add the new instance.  This will not affect my "associated" top-level domain objects as they will be "transient/non-serialized"...therefore not added to the DB.  Purging with cascades should ensure that multiple objects with the same "Identity" will not be created. For collections of "top-level domain object", i.e. List<Bar>, I will use a List<BarRef>.  The BarRef contains a barId and a transient Bar instance. 

This is all hypothetical as OODBMS (db4o) is fairly new to me. I plan on posting my results on how this turns out and if there were any changes in my approach.  If someone else has attempted to solve these problems I have mentioned and have a better solution, please, by all means, let me know so I don't recreate the wheel.

 

Albert Kwan
New Member
New Member
Albert Kwan

--
17 Oct 2006 07:50 AM  

db4o Replication System (dRS) maybe able to help. It helps you to replicate objects from RDBMS to db4o. When an object is replicated, dRS creates a UUID for it and memorizes this object has been replicated.

Take a look:

http://developer.db4o.com/blogs/pro...aspx 

http://www.db4o.com/about/productin...s/drs.aspx

http://developer.db4o.com/ProjectSp...ion_Design

http://www.onjava.com/pub/a/onjava/2006/04/12/object-to-relational-database-replciation-with-db40.html 

dougleeper
New Member
New Member
dougleeper

--
17 Oct 2006 06:02 PM  
Unfortunately this will not work in this case as the mobile application in question will be used by the public and we have strict security concerns.  From a security standpoint, we will not be opening any access to the RDBMS except through our defined user interfaces and web services.  Even these have secured access.
You are not authorized to post a reply.
Forums > English Forums > db4o User Forum

Active Forums 4.2
Close
Copyright ©2000-2010 by Versant Corp.
Privacy Policy