Search code examples
sqlmysqlone-to-oneschema-designdatabase-design

In SQL / MySQL, are there reasons not to put one-to-one relationship in the same table?


One-to-one relationship could usually be stored in the same table. Are there reasons not to store them in the same table?


Solution

  • Number and type of columns. There is a limit on the size of the columns in a table. See here. There is a maximum of 8,060 bytes per row.

    Very large tables can also affect performance and can be difficult to optimize and index well.

    This is apart from keeping data the is conceptually different, apart from each other. For example, a country and currency have a 1 to 1 relationship (illustrative example, I know this is not always the case). I would still not keep them together.