热门面试题与答案和在线测试
面向面试准备、在线测试、教程与实战练习的学习平台

通过聚焦学习路径、模拟测试和面试实战内容持续提升技能。

WithoutBook 将分主题面试题、在线练习测试、教程和对比指南整合到一个响应式学习空间中。

Chapter 6

Joins, Relationships, Constraints, Normalization, and Data Modeling

Learn how Oracle DB models connected business entities and how good design protects consistency and reporting quality.

Inside this chapter

  1. Relational Thinking
  2. Primary Keys and Foreign Keys
  3. Joining Tables for Useful Results
  4. Normalization and Design Tradeoffs

Series navigation

Study the chapters in order for the clearest path from Oracle SQL basics to PL/SQL, recovery, tuning, and enterprise operations. Use the navigation at the bottom of each page to move through the full series.

Tutorial Home

Chapter 6

Relational Thinking

The real strength of a relational database appears when tables connect meaningfully. Customers place orders. Orders contain items. Employees belong to departments. Students register for courses. Instead of copying the same facts many times, Oracle DB lets you model relationships cleanly and query them later.

Chapter 6

Primary Keys and Foreign Keys

CREATE TABLE order_items (
    order_item_id NUMBER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
    order_id NUMBER NOT NULL,
    product_id NUMBER NOT NULL,
    quantity NUMBER NOT NULL,
    unit_price NUMBER(10,2) NOT NULL,
    CONSTRAINT fk_order_items_orders
        FOREIGN KEY (order_id) REFERENCES orders(order_id),
    CONSTRAINT fk_order_items_products
        FOREIGN KEY (product_id) REFERENCES products(product_id)
);

Foreign keys protect referential integrity and prevent broken relationships from entering the system.

Chapter 6

Joining Tables for Useful Results

SELECT
    o.order_id,
    c.full_name,
    o.order_status,
    o.order_date
FROM orders o
JOIN customers c ON c.customer_id = o.customer_id
WHERE o.order_status = 'PENDING';

Joins are essential for enterprise reporting, operational dashboards, and application services. Deep join understanding marks a big step from beginner to intermediate SQL skill.

Chapter 6

Normalization and Design Tradeoffs

Normalization reduces unnecessary duplication and helps preserve data quality. Customer information belongs in the customer table rather than duplicated across every order. At the same time, some duplication may be intentional for history or performance reasons. Advanced design is about understanding those tradeoffs clearly.

版权所有 © 2026,WithoutBook。