I should correct my previous post. I wrote it during process of
learning things :)
Rewamped version:
1) I would put somehere basic recommendations for beginners. Rule
about immutable identity keys, as I wrote above.
2) What I wanted to say. Reverse lookup is good. Actually it is the
only solution we have. But it smells like workaround. We are splitting
documents into chunks.. why? Because we need more than one unique
keys. Why document simply can't have more identity keys, therefore
unique keys?
public class User
{
[RavenKey]
public string Id { get; set; }
[RavenKey]
public string EmailAddress { get; set; }
[RavenKey]
public string PhoneNumber { get; set; }
public string Password { get; set; }
}
I do not see any pitfall.
On 30 čvn, 19:42, Ayende Rahien <
aye...@ayende.com> wrote:
> inline
>
> On Fri, Jun 25, 2010 at 2:26 PM, Daniel Steigerwald
> <
dan...@steigerwald.cz>wrote:
>
>
>
>
>
> > I would like to summarize my investigations and show approach I chose.
> > Problem definition: we need unique keys, for example: email and phone
> > number.
>
> > public class User
> > {
> > public string Id { get; set; }
> > public string EmailAddress { get; set; }
> > public string PhoneNumber { get; set; }
> > public string Password { get; set; }
> > }
>
> > How ensure unique key in RavenDB? Straightforward approach would be to
> > chose native unique key, for example email or phone number. But, which
> > one?
> > Personally I suppose this approach is actually anti-pattern, unless
> > such key is absolute unique immutable value, like social security
> > number (I hope they are really immutable in your country, in my
> > country it's not always true ;)
>
> Agreed on that.
> _every single time_ thatI tried to use a natural key I got bitten by it.
>
> > Second approach was suggested by Ayende, he calls it reverse lookup.
> > emails/...@
bla.com = { "user_id": "users/132" }