Search code examples
databasejdbcrdbms

Why are duplicate rows not allowed in a relational database?


In this introductory tutorial on JDBC and Relational Databases, it is stated,

Integrity Rules

Relational tables follow certain integrity rules to ensure that the data they contain stay accurate and are always accessible. First, the rows in a relational table should all be distinct. If there are duplicate rows, there can be problems resolving which of two possible selections is the correct one.

But if the rows are duplicate, it means all the fields in both the rows hold the same values; and when they are completely same (duplicate), how does the question of one being correct and the other being incorrect arise? How does the duplication of a row harm the data integrity?


Solution

  • The main reason could be:

    1. Wastage of space for maintaining duplicate records which doesn't make sense.
    2. Unnecessary wastage of memory space (main memory) when you select data in your application.
    3. Normalization Constraint: if your table has duplicate records then it's not a normalized table at all.
    4. If 2 record exists for a single person then it's really confusing cause there could be one more customer with same name, address etc. Example: Bank customer.

    So if you don't define a way to distinctly identify the person then how will you say that the account X belongs to which person.