Results 1 to 2 of 2

Thread: PK/FK Indexes

  1. #1
    Join Date
    Feb 2014
    Posts
    2

    Unanswered: PK/FK Indexes

    This question related to DB2 V10 Z/OS.

    If I have a child table, that it's primary key is basically it's parent plus one other column, do I really need an index over just the columns of the FK to support RI? Wouldn't the columns contained in the PK do the same thing? I am asking because the system I am working on contains 300 hundred parent/child type relationships, and I am looking to decrease index usage.

  2. #2
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    Quote Originally Posted by spohnsoftware View Post
    This question related to DB2 V10 Z/OS.

    If I have a child table, that it's primary key is basically it's parent plus one other column, do I really need an index over just the columns of the FK to support RI? Wouldn't the columns contained in the PK do the same thing? I am asking because the system I am working on contains 300 hundred parent/child type relationships, and I am looking to decrease index usage.
    In that situation, you did not need an index over just the FK column, so long as the first column in the index is the same as PK of the parent.

    Actually, you don't absolutely need an index on every FK. It all depends on the SQL statements issued against the table, and also the Parent table (such as when you try and delete a parent row and DB2 needs to insure no children exist).
    M. A. Feldman
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows
    IBM Certified DBA on DB2 for z/OS and OS/390

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •