Discussion:
Questions about relations across multiple databases and squuids
Robert Stuttaford
2012-12-10 08:55:02 UTC
Permalink
I have a single database which I am now breaking up into three, as these 3
parts have differing scaling and data redundancy requirements.

I want to maintain relationships between entities in these databases. I'm
guessing I can't use :db.type/ref to do this, presumably because it wants
entities that actually exist in the same database? If not, can I use
:db.type/long to store the :db/id values instead?

Separately, we're currently putting uuids (from java.util.UUID/randomUUID)
on our entities right now. Do we actually need to do this? I ask because
I'm wondering whether it'd just be simpler to pass :db/id values directly
(e.g. in url querystrings), and ensure they're cast to Long when ever
they're used in a query.

Given that I want to use multiple databases now, is it safe to assume that
:db/id values are unique across databases?

If not, and it turns out we DO need to use uuids, I'm guessing we should be
using squuid instead?
--
-- You received this message because you are subscribed to the Google Groups Datomic group. To post to this group, send email to ***@googlegroups.com. To unsubscribe from this group, send email to datomic+***@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/datomic?hl=en
Mads Olsen
2012-12-10 09:31:23 UTC
Permalink
*cf. *
https://groups.google.com/forum/?fromgroups=#!searchin/datomic/unique$20entity$20ids$20across$20databases/datomic/-ZESEw2ee1s/PDWIlwu9PGoJ

On Mon, Dec 10, 2012 at 9:55 AM, Robert Stuttaford <
Post by Robert Stuttaford
I have a single database which I am now breaking up into three, as these 3
parts have differing scaling and data redundancy requirements.
I want to maintain relationships between entities in these databases. I'm
guessing I can't use :db.type/ref to do this, presumably because it wants
entities that actually exist in the same database? If not, can I use
:db.type/long to store the :db/id values instead?
Separately, we're currently putting uuids (from java.util.UUID/randomUUID)
on our entities right now. Do we actually need to do this? I ask because
I'm wondering whether it'd just be simpler to pass :db/id values directly
(e.g. in url querystrings), and ensure they're cast to Long when ever
they're used in a query.
Given that I want to use multiple databases now, is it safe to assume that
:db/id values are unique across databases?
If not, and it turns out we DO need to use uuids, I'm guessing we should
be using squuid instead?
--
-- You received this message because you are subscribed to the Google
Groups Datomic group. To post to this group, send email to
at https://groups.google.com/d/forum/datomic?hl=en
--
-- You received this message because you are subscribed to the Google Groups Datomic group. To post to this group, send email to ***@googlegroups.com. To unsubscribe from this group, send email to datomic+***@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/datomic?hl=en
Robert Stuttaford
2012-12-10 16:10:34 UTC
Permalink
Mads, am I to infer from your response that I should use squuids, and not
try to use :db.type/ref with :db/id long values?
Post by Mads Olsen
*cf. *
https://groups.google.com/forum/?fromgroups=#!searchin/datomic/unique$20entity$20ids$20across$20databases/datomic/-ZESEw2ee1s/PDWIlwu9PGoJ
Post by Robert Stuttaford
I have a single database which I am now breaking up into three, as these
3 parts have differing scaling and data redundancy requirements.
I want to maintain relationships between entities in these databases. I'm
guessing I can't use :db.type/ref to do this, presumably because it wants
entities that actually exist in the same database? If not, can I use
:db.type/long to store the :db/id values instead?
Separately, we're currently putting uuids
(from java.util.UUID/randomUUID) on our entities right now. Do we actually
need to do this? I ask because I'm wondering whether it'd just be simpler
to pass :db/id values directly (e.g. in url querystrings), and ensure
they're cast to Long when ever they're used in a query.
Given that I want to use multiple databases now, is it safe to assume
that :db/id values are unique across databases?
If not, and it turns out we DO need to use uuids, I'm guessing we should
be using squuid instead?
--
-- You received this message because you are subscribed to the Google
Groups Datomic group. To post to this group, send email to
options, visit this group at
https://groups.google.com/d/forum/datomic?hl=en
--
-- You received this message because you are subscribed to the Google Groups Datomic group. To post to this group, send email to ***@googlegroups.com. To unsubscribe from this group, send email to datomic+***@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/datomic?hl=en
Stuart Halloway
2012-12-10 16:15:11 UTC
Permalink
Squuids or external identifiers in your domain, yes.

Stu

On Mon, Dec 10, 2012 at 11:10 AM, Robert Stuttaford
Post by Robert Stuttaford
Mads, am I to infer from your response that I should use squuids, and not
try to use :db.type/ref with :db/id long values?
Post by Mads Olsen
cf.
https://groups.google.com/forum/?fromgroups=#!searchin/datomic/unique$20entity$20ids$20across$20databases/datomic/-ZESEw2ee1s/PDWIlwu9PGoJ
Post by Robert Stuttaford
I have a single database which I am now breaking up into three, as these
3 parts have differing scaling and data redundancy requirements.
I want to maintain relationships between entities in these databases. I'm
guessing I can't use :db.type/ref to do this, presumably because it wants
entities that actually exist in the same database? If not, can I use
:db.type/long to store the :db/id values instead?
Separately, we're currently putting uuids (from
java.util.UUID/randomUUID) on our entities right now. Do we actually need to
do this? I ask because I'm wondering whether it'd just be simpler to pass
:db/id values directly (e.g. in url querystrings), and ensure they're cast
to Long when ever they're used in a query.
Given that I want to use multiple databases now, is it safe to assume
that :db/id values are unique across databases?
If not, and it turns out we DO need to use uuids, I'm guessing we should
be using squuid instead?
--
-- You received this message because you are subscribed to the Google
Groups Datomic group. To post to this group, send email to
https://groups.google.com/d/forum/datomic?hl=en
--
-- You received this message because you are subscribed to the Google Groups
Datomic group. To post to this group, send email to
https://groups.google.com/d/forum/datomic?hl=en
--
-- You received this message because you are subscribed to the Google Groups Datomic group. To post to this group, send email to ***@googlegroups.com. To unsubscribe from this group, send email to datomic+***@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/datomic?hl=en
Mads Olsen
2012-12-10 16:29:59 UTC
Permalink
Yes, use whatever makes sense for your application, but don't depend on
entity ids for inter-db references.
ie. longs will be fine, as long as you generate them yourself and carefully
avoid clashes between dbs.
In particular forget about :db.type/ref

/Mads
Post by Stuart Halloway
Squuids or external identifiers in your domain, yes.
Stu
On Mon, Dec 10, 2012 at 11:10 AM, Robert Stuttaford
Post by Robert Stuttaford
Mads, am I to infer from your response that I should use squuids, and not
try to use :db.type/ref with :db/id long values?
Post by Mads Olsen
cf.
https://groups.google.com/forum/?fromgroups=#!searchin/datomic/unique$20entity$20ids$20across$20databases/datomic/-ZESEw2ee1s/PDWIlwu9PGoJ
Post by Robert Stuttaford
Post by Mads Olsen
On Mon, Dec 10, 2012 at 9:55 AM, Robert Stuttaford <
Post by Robert Stuttaford
I have a single database which I am now breaking up into three, as
these
Post by Robert Stuttaford
Post by Mads Olsen
Post by Robert Stuttaford
3 parts have differing scaling and data redundancy requirements.
I want to maintain relationships between entities in these databases.
I'm
Post by Robert Stuttaford
Post by Mads Olsen
Post by Robert Stuttaford
guessing I can't use :db.type/ref to do this, presumably because it
wants
Post by Robert Stuttaford
Post by Mads Olsen
Post by Robert Stuttaford
entities that actually exist in the same database? If not, can I use
:db.type/long to store the :db/id values instead?
Separately, we're currently putting uuids (from
java.util.UUID/randomUUID) on our entities right now. Do we actually
need to
Post by Robert Stuttaford
Post by Mads Olsen
Post by Robert Stuttaford
do this? I ask because I'm wondering whether it'd just be simpler to
pass
Post by Robert Stuttaford
Post by Mads Olsen
Post by Robert Stuttaford
:db/id values directly (e.g. in url querystrings), and ensure they're
cast
Post by Robert Stuttaford
Post by Mads Olsen
Post by Robert Stuttaford
to Long when ever they're used in a query.
Given that I want to use multiple databases now, is it safe to assume
that :db/id values are unique across databases?
If not, and it turns out we DO need to use uuids, I'm guessing we
should
Post by Robert Stuttaford
Post by Mads Olsen
Post by Robert Stuttaford
be using squuid instead?
--
-- You received this message because you are subscribed to the Google
Groups Datomic group. To post to this group, send email to
https://groups.google.com/d/forum/datomic?hl=en
--
-- You received this message because you are subscribed to the Google
Groups
Post by Robert Stuttaford
Datomic group. To post to this group, send email to
group at
Post by Robert Stuttaford
https://groups.google.com/d/forum/datomic?hl=en
--
-- You received this message because you are subscribed to the Google
Groups Datomic group. To post to this group, send email to
at https://groups.google.com/d/forum/datomic?hl=en
--
-- You received this message because you are subscribed to the Google Groups Datomic group. To post to this group, send email to ***@googlegroups.com. To unsubscribe from this group, send email to datomic+***@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/datomic?hl=en
Robert Stuttaford
2012-12-10 16:47:30 UTC
Permalink
Thanks guys.

So, just to sanity check, in terms of multi-database queries, I'd be doing something like:

[:find ?those
:in $database1 $database2 ?this
:where
[$database1 ?this :those/squuids ?v]
[$database2 ?those :some/squuid ?v]]
Post by Stuart Halloway
Squuids or external identifiers in your domain, yes.
Stu
On Mon, Dec 10, 2012 at 11:10 AM, Robert Stuttaford
Post by Robert Stuttaford
Mads, am I to infer from your response that I should use squuids, and not
try to use :db.type/ref with :db/id long values?
Post by Mads Olsen
cf.
https://groups.google.com/forum/?fromgroups=#!searchin/datomic/unique$20entity$20ids$20across$20databases/datomic/-ZESEw2ee1s/PDWIlwu9PGoJ
Post by Robert Stuttaford
I have a single database which I am now breaking up into three, as these
3 parts have differing scaling and data redundancy requirements.
I want to maintain relationships between entities in these databases. I'm
guessing I can't use :db.type/ref to do this, presumably because it wants
entities that actually exist in the same database? If not, can I use
:db.type/long to store the :db/id values instead?
Separately, we're currently putting uuids (from
java.util.UUID/randomUUID) on our entities right now. Do we actually need to
do this? I ask because I'm wondering whether it'd just be simpler to pass
:db/id values directly (e.g. in url querystrings), and ensure they're cast
to Long when ever they're used in a query.
Given that I want to use multiple databases now, is it safe to assume
that :db/id values are unique across databases?
If not, and it turns out we DO need to use uuids, I'm guessing we should
be using squuid instead?
--
-- You received this message because you are subscribed to the Google
Groups Datomic group. To post to this group, send email to
https://groups.google.com/d/forum/datomic?hl=en
--
-- You received this message because you are subscribed to the Google Groups
Datomic group. To post to this group, send email to
https://groups.google.com/d/forum/datomic?hl=en
--
--
-- You received this message because you are subscribed to the Google Groups Datomic group. To post to this group, send email to ***@googlegroups.com. To unsubscribe from this group, send email to datomic+***@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/datomic?hl=en
Mads Olsen
2012-12-10 17:27:23 UTC
Permalink
yes

On Mon, Dec 10, 2012 at 5:47 PM, Robert Stuttaford <
Post by Robert Stuttaford
Thanks guys.
[:find ?those
:in $database1 $database2 ?this
:where
[$database1 ?this :those/squuids ?v]
[$database2 ?those :some/squuid ?v]]
Post by Stuart Halloway
Squuids or external identifiers in your domain, yes.
Stu
On Mon, Dec 10, 2012 at 11:10 AM, Robert Stuttaford
Post by Robert Stuttaford
Mads, am I to infer from your response that I should use squuids, and
not
Post by Stuart Halloway
Post by Robert Stuttaford
try to use :db.type/ref with :db/id long values?
Post by Mads Olsen
cf.
https://groups.google.com/forum/?fromgroups=#!searchin/datomic/unique$20entity$20ids$20across$20databases/datomic/-ZESEw2ee1s/PDWIlwu9PGoJ
Post by Stuart Halloway
Post by Robert Stuttaford
Post by Mads Olsen
On Mon, Dec 10, 2012 at 9:55 AM, Robert Stuttaford <
Post by Robert Stuttaford
I have a single database which I am now breaking up into three, as
these
Post by Stuart Halloway
Post by Robert Stuttaford
Post by Mads Olsen
Post by Robert Stuttaford
3 parts have differing scaling and data redundancy requirements.
I want to maintain relationships between entities in these databases.
I'm
Post by Stuart Halloway
Post by Robert Stuttaford
Post by Mads Olsen
Post by Robert Stuttaford
guessing I can't use :db.type/ref to do this, presumably because it
wants
Post by Stuart Halloway
Post by Robert Stuttaford
Post by Mads Olsen
Post by Robert Stuttaford
entities that actually exist in the same database? If not, can I use
:db.type/long to store the :db/id values instead?
Separately, we're currently putting uuids (from
java.util.UUID/randomUUID) on our entities right now. Do we actually
need to
Post by Stuart Halloway
Post by Robert Stuttaford
Post by Mads Olsen
Post by Robert Stuttaford
do this? I ask because I'm wondering whether it'd just be simpler to
pass
Post by Stuart Halloway
Post by Robert Stuttaford
Post by Mads Olsen
Post by Robert Stuttaford
:db/id values directly (e.g. in url querystrings), and ensure they're
cast
Post by Stuart Halloway
Post by Robert Stuttaford
Post by Mads Olsen
Post by Robert Stuttaford
to Long when ever they're used in a query.
Given that I want to use multiple databases now, is it safe to assume
that :db/id values are unique across databases?
If not, and it turns out we DO need to use uuids, I'm guessing we
should
Post by Stuart Halloway
Post by Robert Stuttaford
Post by Mads Olsen
Post by Robert Stuttaford
be using squuid instead?
--
-- You received this message because you are subscribed to the Google
Groups Datomic group. To post to this group, send email to
to
Post by Stuart Halloway
Post by Robert Stuttaford
Post by Mads Olsen
Post by Robert Stuttaford
https://groups.google.com/d/forum/datomic?hl=en
--
-- You received this message because you are subscribed to the Google
Groups
Post by Stuart Halloway
Post by Robert Stuttaford
Datomic group. To post to this group, send email to
group at
Post by Stuart Halloway
Post by Robert Stuttaford
https://groups.google.com/d/forum/datomic?hl=en
--
-- You received this message because you are subscribed to the Google
Groups Datomic group. To post to this group, send email to
at https://groups.google.com/d/forum/datomic?hl=en
--
-- You received this message because you are subscribed to the Google
Groups Datomic group. To post to this group, send email to
at https://groups.google.com/d/forum/datomic?hl=en
--
-- You received this message because you are subscribed to the Google Groups Datomic group. To post to this group, send email to ***@googlegroups.com. To unsubscribe from this group, send email to datomic+***@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/datomic?hl=en
Dustin Getz
2017-07-11 21:15:12 UTC
Permalink
Why must I avoid storing entity-ids from one db into another? If ?eid is
known to be a valid dbid in $A, can I now store ?eid as a long in $B? the
id will never change, i dont see the problem. It doesn't matter if there
are collisions as long as my attribute semantics in $B are such that only
ids from $A will be stored. Have I missed something?
--
You received this message because you are subscribed to the Google Groups "Datomic" group.
To unsubscribe from this group and stop receiving emails from it, send an email to datomic+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Daniel Compton
2017-07-12 01:48:01 UTC
Permalink
The id could change if you ever rebuilt your Datomic database. I'm not sure
how common that is, but it seems to be something that people mention from
time to time, for example:
https://groups.google.com/forum/#!topic/datomic/tKsMsWgVdPw.
Post by Dustin Getz
Why must I avoid storing entity-ids from one db into another? If ?eid is
known to be a valid dbid in $A, can I now store ?eid as a long in $B? the
id will never change, i dont see the problem. It doesn't matter if there
are collisions as long as my attribute semantics in $B are such that only
ids from $A will be stored. Have I missed something?
--
You received this message because you are subscribed to the Google Groups "Datomic" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Datomic" group.
To unsubscribe from this group and stop receiving emails from it, send an email to datomic+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...