how to make this database?

Discussion in 'Databases' started by runeveryday, Sep 7, 2009.

  1. #1
    a database within a human resources database that stores the manager-subordinate relationship.

    we’ll impose the business rule that each manager may have one or more subordinates while each subordinate may have only one manager.


    how many tables shoud i make ? and how many rows and columns i should make.
    thanks in advance!

    may i use this method to design?i use 1 table to achieve the result?
    eg:i use number 00, 01...to stands for the manger.the table is
     
    ID NAME   identity          manager
    1    jim      saler               00
    
    2   bob     programmer         01
    
     
    Code (markup):
     
    runeveryday, Sep 7, 2009 IP
  2. plog

    plog Peon

    Messages:
    298
    Likes Received:
    11
    Best Answers:
    1
    Trophy Points:
    0
    #2
    1 table:

    subordinate_id (primary key), manager_id, firstname, lastname, etc.

    The field manager_id is a foreign key of another record's sub_id. That means managers get inserted first, then subordinates. That way you can pull the managers id and insert it with subordinates records. This enforces that a subordinate can only have 1 manager.

    As an example, Steve and Dave work for Bob, Jerry currently has no subordinates:

    subordinate_id manager_id firstname
    1 (null) Bob
    2 1 Steve
    3 (null) Jerry
    4 1 Dave
     
    plog, Sep 8, 2009 IP