You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Tables whose primary keys have zero attributes #113
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.
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.
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.
Activity
dimitri-yatsenko commentedon Jun 30, 2015
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 commentedon Sep 10, 2015
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 commentedon 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
to the primary key. It cannot be fetched or inserted or updated and is not shown in previews.
austin-hilberg commentedon Sep 30, 2018
Corresponding issue created for datajoint-matlab
4 remaining items
[-]Relations whose primary keys have zero attributes[/-][+]Tables whose primary keys have zero attributes[/+]drewyangdev commentedon Mar 14, 2025
This issue is closed because there has been no activity for more than 365 days, please reopen if it's still applicable.
feat: Add singleton tables (empty primary keys)
docs: Add singleton tables documentation