﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>Matt Johnson commented on RavenDB And Not Having Foreign Keys</title><description>@Justin &amp; @Steve - RavenDB can actually work with full temporal and bitemporal data using https://github.com/mj1856/RavenDB-TemporalVersioning
</description><link>http://ayende.com/161153/ravendb-and-not-having-foreign-keys#comment18</link><guid>http://ayende.com/161153/ravendb-and-not-having-foreign-keys#comment18</guid><pubDate>Fri, 29 Mar 2013 21:13:00 GMT</pubDate></item><item><title>Phillip Haydon commented on RavenDB And Not Having Foreign Keys</title><description>I wrote up something similar last year, but I refer to them as Relationships or References. 

http://www.philliphaydon.com/2012/07/ravendb-what-am-i-persisting-what-am-i-querying-part-2/</description><link>http://ayende.com/161153/ravendb-and-not-having-foreign-keys#comment17</link><guid>http://ayende.com/161153/ravendb-and-not-having-foreign-keys#comment17</guid><pubDate>Fri, 01 Mar 2013 00:59:06 GMT</pubDate></item><item><title>Ayende Rahien commented on RavenDB And Not Having Foreign Keys</title><description>Gene,
In any such scenarios, you usually have the product id as well as any other pertinent information.</description><link>http://ayende.com/161153/ravendb-and-not-having-foreign-keys#comment16</link><guid>http://ayende.com/161153/ravendb-and-not-having-foreign-keys#comment16</guid><pubDate>Thu, 28 Feb 2013 06:57:37 GMT</pubDate></item><item><title>Gene Hughson commented on RavenDB And Not Having Foreign Keys</title><description>I have to agree with all those who think snapshotting data is a poor attempt to fix the issue of a changing product dimension.  It may prevent changes to the product data from corrupting the line items table, but it slams the door on a lot of other likely needs (e.g. tracking sales of the same product across name changes, analyzing price change effects on sales, etc.).  If your particular application doesn't need that kind of referential integrity, then fine, but for something like the example, You Are Gonna Need It (and will be poorly positioned to get it).</description><link>http://ayende.com/161153/ravendb-and-not-having-foreign-keys#comment15</link><guid>http://ayende.com/161153/ravendb-and-not-having-foreign-keys#comment15</guid><pubDate>Wed, 27 Feb 2013 17:43:51 GMT</pubDate></item><item><title>Justin commented on RavenDB And Not Having Foreign Keys</title><description>Temporal data is no excuse for denormalizing or removing FK's. This problem was solved in the late 90's for relational databases using bitemporal tables.

Read http://www.cs.arizona.edu/~rts/tdbbook.pdf if you want to implement orders with products while still being able to see the product as it was at the time of the order or as it is now or any time in between without duplicating data elements in multiple places.

Oracle, DB2 and Teradata all have the SQL temporal standards implemented so you don't have to do it manually.</description><link>http://ayende.com/161153/ravendb-and-not-having-foreign-keys#comment14</link><guid>http://ayende.com/161153/ravendb-and-not-having-foreign-keys#comment14</guid><pubDate>Wed, 27 Feb 2013 16:18:50 GMT</pubDate></item><item><title>Mike Minutillo commented on RavenDB And Not Having Foreign Keys</title><description>I really dislike these inter-aggregate FKs in RDBMS because it's so common to see someone generate an EF (or LLBLGen, or whatever) layer over the top and end up with a bunch of navigation properties that are never (or rarely) used. These tend to either cause unintended lazy-loading or end up as null-reference exceptions.</description><link>http://ayende.com/161153/ravendb-and-not-having-foreign-keys#comment13</link><guid>http://ayende.com/161153/ravendb-and-not-having-foreign-keys#comment13</guid><pubDate>Wed, 27 Feb 2013 03:31:53 GMT</pubDate></item><item><title>Steve Py commented on RavenDB And Not Having Foreign Keys</title><description>@phil - Because to be in any way reliable this requires temporal data. Otherwise you have two pieces of related data at some point in time that will certainly conflict with one another. An example of this would be when a product's price changes. A customer comes back to dispute a price, the order says it was $500, the product says $450. The system has no record whether the product price was updated, let alone whether it was updated before or after the order was received. Real world scenarios will be more complicated, but keeping that product reference is only practically useful if the data supports a full append-only timestamp model. If it isn't crucially important to have that, then YAGNI.</description><link>http://ayende.com/161153/ravendb-and-not-having-foreign-keys#comment12</link><guid>http://ayende.com/161153/ravendb-and-not-having-foreign-keys#comment12</guid><pubDate>Wed, 27 Feb 2013 03:06:35 GMT</pubDate></item><item><title>Phil Degenhardt commented on RavenDB And Not Having Foreign Keys</title><description>Snapshotting the relevant data is perfectly fine but it does not have to mean that the association should be discarded. Why not maintain both the association and the relevant snapshot? The association connects this entity to other entities in the system and thus permits analysis, which wasn't initially conceived, to be bolted onto the system later and applied retrospectively. Discarding the association seems to be taking YAGNI one step too far. </description><link>http://ayende.com/161153/ravendb-and-not-having-foreign-keys#comment11</link><guid>http://ayende.com/161153/ravendb-and-not-having-foreign-keys#comment11</guid><pubDate>Tue, 26 Feb 2013 23:32:08 GMT</pubDate></item><item><title>Scooletz commented on RavenDB And Not Having Foreign Keys</title><description>@Rafal +1 
having no option of adding or not an FK it's not a feature. It's implementation/design decision which one have to live with. I'm not saying it's needed for document database like Raven. I'm saying that not having it is not a plus for the db.</description><link>http://ayende.com/161153/ravendb-and-not-having-foreign-keys#comment10</link><guid>http://ayende.com/161153/ravendb-and-not-having-foreign-keys#comment10</guid><pubDate>Tue, 26 Feb 2013 20:40:10 GMT</pubDate></item><item><title>Tim Murphy commented on RavenDB And Not Having Foreign Keys</title><description>+1 David. I was going to make the same comment.

Whether it is a NoSQL or SQL database OrderLines must shield itself from changes to the Products by at least keeping the name and unit price at time of order.</description><link>http://ayende.com/161153/ravendb-and-not-having-foreign-keys#comment9</link><guid>http://ayende.com/161153/ravendb-and-not-having-foreign-keys#comment9</guid><pubDate>Tue, 26 Feb 2013 19:13:22 GMT</pubDate></item><item><title>David Boike commented on RavenDB And Not Having Foreign Keys</title><description>I think what Oren glossed over, and is critical in understanding this concept if you're coming from the RDBMS, is that when we model Order and OrderLines in a document database, we note the ProductID but we also bring in a few critical pieces of the Product as well - maybe just the name.

That way, when the product gets deleted later, it doesn't matter. We have all the information we need to display the details of that order I made 2 years ago.

The real kicker is that in a relational model, if i bought a Widget 2 years ago, and then 1 year ago the Widget product got updated to become a Super Widget, my order history would now indicate that I bought a Super Widget! But I didn't! I only bought a Widget!

By bringing the product name into the Order + OrderLines model, we maintain that historical accuracy no matter what happens to the product at some later date, PLUS we don't have to always remember to select where IsDeleted = 0.</description><link>http://ayende.com/161153/ravendb-and-not-having-foreign-keys#comment8</link><guid>http://ayende.com/161153/ravendb-and-not-having-foreign-keys#comment8</guid><pubDate>Tue, 26 Feb 2013 17:10:02 GMT</pubDate></item><item><title>Chris Ammerman commented on RavenDB And Not Having Foreign Keys</title><description>It's less common to see in an app database, but in the Data Warehouse world this is dealt with using "slowly changing dimensions." http://en.m.wikipedia.org/wiki/Slowly_changing_dimension#section_7 (Usually the "Type 2" kind.)</description><link>http://ayende.com/161153/ravendb-and-not-having-foreign-keys#comment7</link><guid>http://ayende.com/161153/ravendb-and-not-having-foreign-keys#comment7</guid><pubDate>Tue, 26 Feb 2013 12:51:12 GMT</pubDate></item><item><title>Gilligan commented on RavenDB And Not Having Foreign Keys</title><description>I think  we have in the past used foreign keys thinking something like "Hey, now we don't have to think about this relationship in the domain". But despite our efforts to hide aspects of the domain from our minds, it comes back to haunt us. Foreign keys aren't a silver bullet and do end up causing much pain. The number of times I have seen "IsDeleted" and the pain that has also caused is astounding. I think Oren is saying exactly this: we cannot hide these relationships magically from the domain. We must face them head on in our app and deal with them from a business perspective. </description><link>http://ayende.com/161153/ravendb-and-not-having-foreign-keys#comment6</link><guid>http://ayende.com/161153/ravendb-and-not-having-foreign-keys#comment6</guid><pubDate>Tue, 26 Feb 2013 12:17:46 GMT</pubDate></item><item><title>Jon Samwell commented on RavenDB And Not Having Foreign Keys</title><description>@alastair -  nullable fk's are evil and will just lead to confusion in the relational db world and cascade deletes cause pain.  I think what Oren is trying to say is you cannot approach document db's the same way you approach relational.  The things we have to do to keep relational databases happy do not exists when you look at the NOSQL paradigm.</description><link>http://ayende.com/161153/ravendb-and-not-having-foreign-keys#comment5</link><guid>http://ayende.com/161153/ravendb-and-not-having-foreign-keys#comment5</guid><pubDate>Tue, 26 Feb 2013 11:28:16 GMT</pubDate></item><item><title>Ayende Rahien commented on RavenDB And Not Having Foreign Keys</title><description>Mango
I don't follow the question</description><link>http://ayende.com/161153/ravendb-and-not-having-foreign-keys#comment4</link><guid>http://ayende.com/161153/ravendb-and-not-having-foreign-keys#comment4</guid><pubDate>Tue, 26 Feb 2013 11:27:17 GMT</pubDate></item><item><title>Mango commented on RavenDB And Not Having Foreign Keys</title><description>Ayende,

...i'm new to raven ...wath's about the costo of separate aggregates life cycles?

tyhanks
</description><link>http://ayende.com/161153/ravendb-and-not-having-foreign-keys#comment3</link><guid>http://ayende.com/161153/ravendb-and-not-having-foreign-keys#comment3</guid><pubDate>Tue, 26 Feb 2013 11:14:29 GMT</pubDate></item><item><title>alastair commented on RavenDB And Not Having Foreign Keys</title><description>Many RDBMS will allow you to specify DELETE behaviour such that deleting the parent record will automatically set the childs key to NULL in this situation.</description><link>http://ayende.com/161153/ravendb-and-not-having-foreign-keys#comment2</link><guid>http://ayende.com/161153/ravendb-and-not-having-foreign-keys#comment2</guid><pubDate>Tue, 26 Feb 2013 10:41:23 GMT</pubDate></item><item><title>Rafal commented on RavenDB And Not Having Foreign Keys</title><description>Are you saing that not having inter-document consistency checks in the DB is an advantage over having them? I beg to differ.</description><link>http://ayende.com/161153/ravendb-and-not-having-foreign-keys#comment1</link><guid>http://ayende.com/161153/ravendb-and-not-having-foreign-keys#comment1</guid><pubDate>Tue, 26 Feb 2013 10:36:15 GMT</pubDate></item></channel></rss>