Data Base design (Table Relationships)

  • I have a 'Root' table with 8 columns.

    First 5 columns in 'Root table ' are used in all 10 child tables of that root table.

    I first wanted to make the first 5 columns of the 'root' table as Composite Primary key ,

    But the data thats going to come into the 5 columns will not be unique (like a column may have same hospital name with different patient numbers starting from 1,2,3----n in the patient column, When the hospital name changes in the Hospital column then the patient number again starts from 1,2,3----n ).

    Note: Both the 'Hospiatal Name' & 'Patient number' are 2 columns among the 5 columns of the root table.

    So as per my requirement ,Client wants to use all the first 5 columns of the root table in other 10 child tables also.

    I am not able to do that as per the nomalization criteria.

    Can anyone please suggest me how to design.

  • If I got you right you could:

    Create an additional table with the 5 colums you mentioned. Add an artificial key to it (of type uniqueidentifier if possible).

    Then, reference in every table to this key (also in your "root" table).

    hope it helps. 🙂

  • A couple things, first, give some DDL and explain the differences in why the columns need. Second, don't consider the rows ordered. There isn't an order to the rows, necessarily, so don't consider that as part of your design.

    A PK requires uniqueness. It enforces it, so if you set that, then you can't have duplicates. Building an index on those columns can help, but it does not need to be a PK. It can be an index to use for queries.

    I tend to favor surrogate keys, like an identity column, if you are not sure of the data.

  • well totally agree to steve .... it seams to be the best best

    regards

    greg

  • -- removed xpost notice because Steve already pointed the other thread --

    Good job, Steve

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

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

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