Relationship Scenarios

  • I am trying to decide on the best relationship scenario for the following:

    Department has one or more Employees

    Department has one or more Divisions

    Divisions have one or more Units

    Units have one or more Groups

    Every employee belongs to a Department, Division, Unit, and a Group.

  • TJT (4/26/2014)


    I am trying to decide on the best relationship scenario for the following:

    Department has one or more Employees

    Department has one or more Divisions

    Divisions have one or more Units

    Units have one or more Groups

    Every employee belongs to a Department, Division, Unit, and a Group.

    [Department]-|---|<[Devision]-|---|<[Unit]-|---|<[Group]-|---|<[Employee]

    😎

  • Yes this is straight forward, but what happens when a person doesn't have a group or a unit, but works just at the divisional level?

    I am trying to imagine all possibilities.

  • TJT (4/26/2014)


    Yes this is straight forward, but what happens when a person doesn't have a group or a unit, but works just at the divisional level?

    I am trying to imagine all possibilities.

    I was kind of waiting for this question, this is a typical Ragged/Unbalanced hierarchy problem.

    😎

    This is one simple way of handling this:

    [Department]-|--,

    [Devision]-|---,|

    [Unit]-|------,||

    [Group]-|----,|||

    ''''--o<[Organizational Unit]-|---|<[Employee]

    More info:

    Inside Microsoft SQL Server 2008: T-SQL Querying (Developer Reference) by Itzik Ben-Gan

    SQL Hierarchies – Parent Child[/url]

  • OK thanks, this is what I was thinking, but wanted confirmation on this.

    Any other thoughts on this are appreciated

  • TJT (4/26/2014)


    OK thanks, this is what I was thinking, but wanted confirmation on this.

    Any other thoughts on this are appreciated

    Kind of a "must read"

    Joe Celko's Trees and Hierarchies in SQL for Smarties

    😎

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply