I am trying to design a database relational model for an assignment. First, I design the ER diagram, and then the relational model with tables (schemas).
Here's my question: Is it possible for an entity to have only one attribute?
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It only takes a minute to sign up.Sign up to join this community
If an entity only has one attribute, then that attribute must serve as an identifier for the entity. Typically, if only one attribute is found for an entity in the given data stream, then another attribute is "invented" for purposes of identifying. It's often called "id", it's often an integer, and it's often populated using the autonumber feature of the database system.
When you are doing analysis, it's important to distinguish between the features that were given to you in the problem statement, and the features you added in order to make sense out of the problem.
Walter Mitty's answer is good, but I'd like to add something.
If the column contains unique values, the surrogate key (the
id column) can be added only for performance reasons. But this makes little sense if the other column is small (integer, date...) and the DBMS does not organise tables by primary key (like InnoDB). Or it does, but the table is almost read-only.
For example, even performance considerations advice against adding a surrogate key, if the other column is something like
On a more theoretical note: an entity can even have zero attributes. Since all tuples and tables are unique by definition, in relational algebra exactly 2 tables exist with 0 columns: one is empty, one has 1 tuple with 0 columns. But in practice, I don't know if such tables can be created in an existing RDBMS, and I don't know if SQL standard allows this.