Title: Relational expressions in foreign key definitions · Issue #436 · datajoint/datajoint-python · GitHub
Open Graph Title: Relational expressions in foreign key definitions · Issue #436 · datajoint/datajoint-python
X Title: Relational expressions in foreign key definitions · Issue #436 · datajoint/datajoint-python
Description: Foreign keys may be more expressively defined using the same relational operators used in queries. Multiple foreign keys made from the primary key, for example, may be viewed as the join: -> Scan -> Method is equivalent to -> Scan.proj()...
Open Graph Description: Foreign keys may be more expressively defined using the same relational operators used in queries. Multiple foreign keys made from the primary key, for example, may be viewed as the join: -> Scan -...
X Description: Foreign keys may be more expressively defined using the same relational operators used in queries. Multiple foreign keys made from the primary key, for example, may be viewed as the join: -> Sca...
Opengraph URL: https://github.com/datajoint/datajoint-python/issues/436
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Relational expressions in foreign key definitions","articleBody":"Foreign keys may be more expressively defined using the same relational operators used in queries. \r\n\r\nMultiple foreign keys made from the primary key, for example, may be viewed as the join:\r\n\r\n```\r\n-\u003e Scan\r\n-\u003e Method\r\n```\r\nis equivalent to \r\n```\r\n-\u003e Scan.proj() * Method.proj()\r\n```\r\nSince only primary keys are used in foreign key references, then the `.proj()` is redundant and we could use simply\r\n```\r\n-\u003e Scan * Method\r\n```\r\n\r\nA particular improvement would result for renamed foreign keys. For example, in the current syntax, to reference to the `User` table as `experimenter, we use the syntax\r\n```\r\n(experimenter) -\u003e User\r\n```\r\nInstead, we could use the `proj` operator for renaming\r\n```\r\n-\u003e User.proj(user=\"experimenter\")\r\n```\r\n\r\nThis becomes particularly useful for more complex cases. Users could actually test the expression before making it a foreign key.\r\n\r\nFor example, let's define a Synapse with references to presynaptic and postsynaptic Cells within a Scan. Currently, this would be declared as\r\n```\r\n# Synapse\r\n-\u003e Scan\r\n(presyn) -\u003e Cell(cell)\r\n(postsyn) -\u003e Cell(cell)\r\n```\r\nInstead it could be defined as \r\n```\r\n# Synapse\r\n-\u003e Scan * Cell.proj(presyn=\"cell\") * Cell.proj(postsyn=\"cell\")\r\n```\r\nFinally, foreign keys to unions (See #324) use the union operator in the foreign key, resulting in more intricate expressions as detailed in that issue.\r\n\r\nThis approach uses the same set of concepts as relational expressions and helps consolidate these ideas in the student's mind.\r\n\r\nAllowed operators are are join, proj, and union. Since `aggr` and restriction have no way of affecting the primary key, they are not allowed. Similarly, `dj.U` is not allowed because it is not referable. \r\n\r\nThe change is not backward compatible for renamed foreign keys if we fully commit to the `proj` syntax. Since renamed foreign keys have not yet gained wide use with less experienced users, I think this is the right time to introduce the change. We could keep both forms for a while and gradually deprecated the old renaming scheme. ","author":{"url":"https://github.com/dimitri-yatsenko","@type":"Person","name":"dimitri-yatsenko"},"datePublished":"2018-01-17T05:43:37.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/436/datajoint-python/issues/436"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:629d41fd-e1e6-d5b9-3fd1-d2e137c0bee1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CA8A:3BEDBF:140E1C2:1BE5DCD:6A4DEB3B |
| html-safe-nonce | 510ec3fe4db0d7e07c7e888dacbfdc35edcbdf84735eab92ac2966ba410a39a1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQThBOjNCRURCRjoxNDBFMUMyOjFCRTVEQ0Q6NkE0REVCM0IiLCJ2aXNpdG9yX2lkIjoiNjg1NjM0MzY1MTE3NTIzMDI2NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 2cc628f6e121feeddf45b3b0419d10888f8cb25edfaf1b1406d66dde5c383171 |
| hovercard-subject-tag | issue:289149013 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/datajoint/datajoint-python/436/issue_layout |
| twitter:image | https://opengraph.githubassets.com/03e0b8b70094e23161f9094ebacc26b453326f1a56ad63eec261b12f4bee0437/datajoint/datajoint-python/issues/436 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/03e0b8b70094e23161f9094ebacc26b453326f1a56ad63eec261b12f4bee0437/datajoint/datajoint-python/issues/436 |
| og:image:alt | Foreign keys may be more expressively defined using the same relational operators used in queries. Multiple foreign keys made from the primary key, for example, may be viewed as the join: -> Scan -... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dimitri-yatsenko |
| hostname | github.com |
| expected-hostname | github.com |
| None | 06b8a6144231bf3a234f1c2e9993861e07ce98a905912b114aa386c2d7e84b33 |
| turbo-cache-control | no-preview |
| go-import | github.com/datajoint/datajoint-python git https://github.com/datajoint/datajoint-python.git |
| octolytics-dimension-user_id | 2375501 |
| octolytics-dimension-user_login | datajoint |
| octolytics-dimension-repository_id | 5866704 |
| octolytics-dimension-repository_nwo | datajoint/datajoint-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 5866704 |
| octolytics-dimension-repository_network_root_nwo | datajoint/datajoint-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 1d344bdb7547fe6bca17a59bb2b8aac3dc9532a0 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width