Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tables whose primary keys have zero attributes #113

Open
dimitri-yatsenko opened this issue Jun 30, 2015 · 4 comments
Open

Tables whose primary keys have zero attributes #113

dimitri-yatsenko opened this issue Jun 30, 2015 · 4 comments
Assignees
Labels
Milestone

Comments

@dimitri-yatsenko
Copy link
Member

Currently datajoint prohibits creating tables with no attributes in the primary key. We can relax this prohibition.

If the primary key has no attributes, it can only have one value. Therefore, the relation can only contain one tuple. So it's good for relations that contain a single fact about the universe rather than a collection of similar facts. The relational algebra using such relations remains identical to what it is now. In particular, joining two relations with no primary key produces another relation with no primary key and one tuple.

@dimitri-yatsenko
Copy link
Member Author

Note that this is different from SQL's tables that don't have a primary key. SQL is not exactly relational and its tables can contain duplicate rows. SQL does not have the equivalent of a primary key with zero attributes as defined here.

@dimitri-yatsenko dimitri-yatsenko self-assigned this Aug 11, 2015
@dimitri-yatsenko dimitri-yatsenko added this to the Release v0.2 milestone Aug 18, 2015
@dimitri-yatsenko
Copy link
Member Author

As @eywalker suggested, one way to think about this topic is to imaging that all tables have an additional attribute _epsilon_ whose domain contains a single value _Omega_. Then a relation with an empty primary key actually has one attribute in the primary key with only one possible value. As such, this relation can contain only one tuple.

@dimitri-yatsenko dimitri-yatsenko removed this from the Release v0.2 milestone Apr 17, 2017
@dimitri-yatsenko dimitri-yatsenko added this to the Release 0.11 milestone Jan 17, 2018
@dimitri-yatsenko
Copy link
Member Author

dimitri-yatsenko commented Jan 17, 2018

If the primary key is empty, the table can have only one row. It is accomplished by adding an invisible column, defined as

_  = 1 : tinyint   # universe 
---

to the primary key. It cannot be fetched or inserted or updated and is not shown in previews.

@austin-hilberg
Copy link
Contributor

Corresponding issue created for datajoint-matlab

@dimitri-yatsenko dimitri-yatsenko modified the milestones: Release 0.12, Release 0.13 Nov 26, 2018
@eywalker eywalker removed this from the Release 0.13 milestone Aug 1, 2019
@dimitri-yatsenko dimitri-yatsenko changed the title Relations whose primary keys have zero attributes Tables whose primary keys have zero attributes Feb 4, 2020
@eywalker eywalker added this to the Concept milestone Apr 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants