{"action":"closed","issue":{"url":"https://api.github.com/repos/JasperFx/marten/issues/628","repository_url":"https://api.github.com/repos/JasperFx/marten","labels_url":"https://api.github.com/repos/JasperFx/marten/issues/628/labels{/name}","comments_url":"https://api.github.com/repos/JasperFx/marten/issues/628/comments","events_url":"https://api.github.com/repos/JasperFx/marten/issues/628/events","html_url":"https://github.com/JasperFx/marten/issues/628","id":191663695,"number":628,"title":"Unable to Represent Hierarchies with Foreign Keys","user":{"login":"cocowalla","id":800977,"avatar_url":"https://avatars.githubusercontent.com/u/800977?v=3","gravatar_id":"","url":"https://api.github.com/users/cocowalla","html_url":"https://github.com/cocowalla","followers_url":"https://api.github.com/users/cocowalla/followers","following_url":"https://api.github.com/users/cocowalla/following{/other_user}","gists_url":"https://api.github.com/users/cocowalla/gists{/gist_id}","starred_url":"https://api.github.com/users/cocowalla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cocowalla/subscriptions","organizations_url":"https://api.github.com/users/cocowalla/orgs","repos_url":"https://api.github.com/users/cocowalla/repos","events_url":"https://api.github.com/users/cocowalla/events{/privacy}","received_events_url":"https://api.github.com/users/cocowalla/received_events","type":"User","site_admin":false},"labels":[{"id":272072662,"url":"https://api.github.com/repos/JasperFx/marten/labels/bug","name":"bug","color":"fc2929","default":true},{"id":272072667,"url":"https://api.github.com/repos/JasperFx/marten/labels/question","name":"question","color":"cc317c","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-11-25T09:55:17Z","updated_at":"2016-11-30T22:09:34Z","closed_at":"2016-11-30T22:09:34Z","body":"I seem to be unable to represent graphs with referential integrity.\r\n\r\nLet's say I want to represent a hierarchy of `Category` objects, such that each one points to its parent:\r\n\r\n```\r\npublic class Category\r\n{\r\n    public Guid Id { get; set; }\r\n    public Guid? ParentId { get; set; }\r\n    public string Name { get; set; }\r\n    ...\r\n}\r\n```\r\nAnd my `MartenRegistry` contains:\r\n\r\n```\r\nFor<Category>()\r\n    .ForeignKey<Category>(x => x.ParentId);\r\n```\r\n\r\nWhen I call `ApplyAllConfiguredChangesToDatabase()`, and exception is thrown with `Cyclic dependency found`.\r\n\r\nThe workaround is to change the `Category` so that the parent is represented as another `Category`, rather than as a `Guid`. But that stores the entire hierarchy in a single database row.\r\n\r\nMaybe I'm still thinking too much in the relational world, but is this by design? Is it normal to store large graphs as JSON in a single database row?"}}
{"actor":{"display_login":"jeremydmiller"}}