I've been successful at using hostname+timestamp to create unique URI's which 
are somewhat meaningful and increasing like

/data/<host> /<timestamp>.xml

Where in this case timestamp is a microsecond long.
This does rely on the fact that I'm not inserting documents fast enough to 
duplicate timestamps, that can be solved with a sequence number.
                /data/<host> /<timestamp>-<seq>.xml




----------------------------------------
David A. Lee
Senior Principal Software Engineer
Epocrates, Inc.
d...@epocrates.com<mailto:d...@epocrates.com>
812-482-5224

From: general-boun...@developer.marklogic.com 
[mailto:general-boun...@developer.marklogic.com] On Behalf Of Jason Hunter
Sent: Friday, December 02, 2011 1:30 AM
To: General MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] Way to realize auto-increment id feature 
in Marklogic

When you're inserting, you're already picking a unique URI for the document.  
You can treat that like its public ID.

Or you can embed another id within the document, like you proposed.

It's not advisable to try to get a monotonically increasing id value from the 
database in a shared-nothing clustered database like MarkLogic.  It creates a 
synchronization hot spot.  We usually choose 64-bit or larger random numbers 
when simple ids are needed.

-jh-

On Dec 1, 2011, at 9:42 PM, Amar Wakkar wrote:


Dear all,

I want to insert a couple of XML documents in the Marklogic database which are 
formed based on the HTTP form submission.

In normal RDBMS, I would have inserted those in a table which has 
auto-increment id column which will return me the id of the latest column 
inserted into the database. I can then use this id value to create links on the 
frontend to access these documents at a later stage for viewing/editing etc.

With Marklogic, I can insert the documents using XCC Java connector or even 
directly through XQuery pages but it does not return the id of the document 
which has been inserted. What would be a good way to realize something similar 
like getting ID of the document to link it back on the frontend? I can generate 
IDs myself and insert it in document but is that how everyone else would handle 
it?

 Thanks and regards,
Amaresh Wakkar
_______________________________________________
General mailing list
General@developer.marklogic.com<mailto:General@developer.marklogic.com>
http://developer.marklogic.com/mailman/listinfo/general

_______________________________________________
General mailing list
General@developer.marklogic.com
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to