1 Reply Latest reply on May 13, 2013 6:57 PM by Bogdan Coman-Oracle

    Hierarchical data structure

      I have to model a solution using DPL that holds an hirarchical tree structure, like this: Manager -> Seller -> Customer

      The tree will be only navigated in descenging way; this mean that if you want to retrieve a specific customer you must know who there parents are. So I will define Manager, Seller and Customer entities, and each entitiy will keep a list of its children.
      For each specif instance of any of these entities there will be an existing user binded to it.
      CRUD operatios will be only availbale from parents to children. So each manager can anly update, delete, etc on it's own sellers, etc.

      We expect to have:
      Managers: 400
      Sellers: 400 per manager -> 400*400 = 160000
      Customers: 500 per seller -> 500*160000=80.000.000

      And also expect an average of 20 write operations by day for each user

      As far as I understood DPL does the magik of creating DBs for you (abstracted by the EntityStore) and there will be a DB per entity. That means that for Customer entity will be a total of 3.2M writes over a DB of 80M records per day.
      I don't know if this to much for BD or not, however I can realize for example that due to nature of this problem there is no need to store al Customers in the same DB, and will be much performant to lookup over a DB of 500 records rather than one of 80M.

      My questions are:

      Is DBDJE DPL the better/a good solution for this problem?
      There is a better modeling option using DPL than propossed one (entities with list of childs)?

      Thanks in advance.
        • 1. Re: Hierarchical data structure
          Bogdan Coman-Oracle

          You can achieve the hierarchical tree structure you're looking for by using Secondary Indices. I will be providing you with the detailed documentation and examples on this, you let me know if you have any questions.

          Class SecondaryIndex: http://docs.oracle.com/cd/E17277_02/html/java/com/sleepycat/persist/SecondaryIndex.html
          Secondary Keys (Using Secondaries with the DPL): http://docs.oracle.com/cd/E17277_02/html/GettingStartedGuide/applicationoverview.html#secondary
          Working with Indices: http://docs.oracle.com/cd/E17277_02/html/GettingStartedGuide/persist_index.html

          The DPL examples are in examples/persist. For secondaries examples you can check EventExampleDPL.java, PersonExample.java, DataAccessor.java.

          Please note that since you are using the DPL you never have to provide a transactional handle when opening an index, be it a primary or a secondary. However, if transactions are enabled for your store, then all of the indexes that you open will be enabled for transactional usage. Moreover, any write operation performed using that index will be done using a transaction, regardless of whether you explicitly provide a transactional handle to the write operation. If you do not explicitly provide a transaction handle to DPL write operations performed on a transactional store, then auto commit is silently used for that operation.