Data Integrity

Data Integrity

Data Integrity means ensuring that the data in a database is accurate, consistent, and reliable over its entire lifecycle. It prevents errors, duplicates, and corruption.

Types of Data Integrity:

  1. Entity Integrity

    • Ensures each row in a table is unique, often using a primary key.

  2. Referential Integrity

    • Ensures relationships between tables stay consistent, using foreign keys to link tables properly.

  3. Domain Integrity

    • Ensures that data entered is valid and follows defined rules, such as data type, format, or range (e.g., age must be a positive number).

  4. User-Defined Integrity

    • Custom rules set by the user or application, such as business logic (e.g., an order date cannot be in the future).


🔍 Indexing

Indexing is a technique to speed up searching and querying data in a database.

  • An index works like the index in a book: it helps the database quickly locate rows without scanning the entire table.

  • Indexes are created on columns that are often used in search conditions (e.g., WHERE clauses).

Benefits of Indexing:

  • Much faster data retrieval

  • Improved performance for SELECT queries

Downsides:

  • Indexes take extra storage space.

  • Slows down INSERT, UPDATE, and DELETE operations slightly because indexes must be updated too.

Note: All information provided on the site is unofficial. You can get official information from the websites of relevant state organizations