Database Design


How is Database Design Important?


Database design is important for the following reasons -

  • Data Integrity and Accuracy: A properly designed database ensures accurate and consistent data across all tables through the use of keys, constraints, and relationships.
  • Improved Query Performance: Efficient design allows the database to process queries faster, saving users time.
  • Reduced Data Redundancy and Duplication: Good design avoids duplicate data, which can lead to inconsistency and wasted storage.
  • Scalability: A well-designed database can grow with the business and handle increasing data volumes without requiring essential changes.
  • Ease of Maintenance: Databases that follow good design principles are more accessible to update and maintain over time, reducing the effort and cost of modifications.
  • Data Security and Access Control: A well-designed database protects sensitive data through access controls, roles, and encryption.

DB2 database design is the process of planning, structuring, and organizing how data will be stored, managed, and accessed in the database. It ensures the database is efficient, scalable, and reliable. There are three major stages involved in designing a database:

  1. Logical Database Design
  2. Physical Database Design
  3. Implementing Database Design

These phases ensure that the database meets both business requirements and technical constraints.

Physical Database Design -


Physical database design focuses on how the data will be stored and accessed efficiently. It involves creating indexes, partitioning tables, and configuring storage settings to improve performance. At this stage, we convert the logical design into physical tables within the DB2 environment.

Key Tasks include:

  • Choosing the appropriate data types for columns.
  • Defining primary keys, foreign keys, and constraints.
  • Deciding on indexes to speed up queries.
  • Configuring tablespaces and storage options.

Steps of Physical Database Design:

  1. Define Table Structures: Convert entities into DB2 tables and attributes into columns.
  2. Choose Data Types: Assign appropriate data types to columns. Example: INT for IDs, VARCHAR for names, DATE for order dates.
  3. Create Indexes for Performance: Create indexes on frequently searched columns to speed up queries.
  4. Design Tablespaces and Storage: Use tablespaces to group tables logically and define where data will be stored. Example: Create a tablespace for customer-related tables.
  5. Define Constraints: Apply primary keys, foreign keys, and check constraints to maintain integrity.

Logical Database Design -


Logical design focuses on what data should be stored and how it is related. It deals with the conceptual structure of the data, identifying entities, attributes, and relationships between them. At this stage, we build an Entity-Relationship (ER) model to represent the data.

  • It does not consider how data will be stored physically (like file structure or indexes).
  • Normalization is applied to avoid redundancy and ensure data integrity.

Steps of Logical Database Design:

  1. Identify Entities and Attributes:
    • Entities represent things or objects in the real world (e.g., Customers, Orders).
    • Attributes are the properties of entities (e.g., Customer Name, Order Date).
  2. Define Relationships Between Entities: Determine how entities relate to each other (One-to-One, One-to-Many, or Many-to-Many). Example: A Customer can place many Orders, establishing a One-to-Many relationship.
  3. Create an ER Diagram: Use Entity-Relationship diagrams to visually represent tables, attributes, and relationships. Example: Customer → Places → Order
  4. Apply Normalization: Break tables into smaller related tables to eliminate redundancy and ensure integrity. Example: Store customer and order details in separate tables to avoid duplicating customer information.

Implementing Database Design -


This phase involves executing the physical design on the DB2 database system. It includes creating tables, constraints, indexes, and loading initial data into the database. Once implemented, the database is tested to ensure it meets requirements. The implementation steps are -

  • Implementing Db2 databases
  • Implementing Db2 storage groups
  • Implementing Db2 table spaces
  • Implementing Db2 tables
  • Implementing Db2 views
  • Implementing Db2 indexes
  • Implementing Db2 schemas
  • Loading data into Db2 tables
  • Implementing Db2 stored procedures
  • Implementing relationships with referential constraints
  • Implementing Db2 triggers
  • Implementing Db2 user-defined functions
  • Implementing Db2 system-defined routines
  • Estimating disk storage for user data