table structure

  • Hello ,

    I need an advice. let me describe.

    I have Main table with this structure:

    id

    id_creator

    id_approver

    id_teacher

    Next 3 tables(creator, apporover, teacher) has the same list of users. I'm thinking to create just one table for all.

    Reason is that I want to send emails to different users(creator,approver,teacher). I created also table emails with id for all of tables

    with structure(id, email)Is it good idea to go this way?

    Sometimes I will need add user, and I would like to avoid updating all these tables.

    Thank you for every comment.

  • Sounds like you're on the right track.



    Alvin Ramard
    Memphis PASS Chapter[/url]

    All my SSC forum answers come with a money back guarantee. If you didn't like the answer then I'll gladly refund what you paid for it.

    For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]

  • Alvin Ramard (11/4/2016)


    Sounds like you're on the right track.

    okay but what is better? to have 3 tables separated or create one table... but, than I must create 3 relationship from one table to main table, is it okay?

  • peter478 (11/4/2016)


    Alvin Ramard (11/4/2016)


    Sounds like you're on the right track.

    okay but what is better? to have 3 tables separated or create one table... but, than I must create 3 relationship from one table to main table, is it okay?

    I would create one user table, with 3 relationships.



    Alvin Ramard
    Memphis PASS Chapter[/url]

    All my SSC forum answers come with a money back guarantee. If you didn't like the answer then I'll gladly refund what you paid for it.

    For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]

  • Quick thought, if you are storing exactly the same information for all "person types" then a single person table could work.

    😎

    +------------+ +-------------+

    | TBL_PERSON | | TBL_MAIN |

    +------------+ +-------------+

    | ID_PERSON |-+--, | id |

    | (DETAIL) | |--------------+<| id_creator |

    +------------+ |--------------+<| id_approver |

    '--------------+<| id_teacher |

    +-------------+

    I would though suggest another pattern which allows for different information stored for each person type in addition to common person attributes

    Common for all Person type specific Main table

    person data

    +------------+ +-------------+ +-------------+

    | TBL_PERSON | | TBL_CREATOR | | TBL_MAIN |

    +------------+ +-------------+ +-------------+

    | ID_PERSON |-+--, | ID_CREATOR |-+-----, | id |

    | (DETAIL) | |----------+<| ID_PERSON | '------+<| id_creator |

    +------------+ | | (DETAIL) | ,--------+<| id_approver |

    | +-------------+ | ,------+<| id_teacher |

    | | | +-------------+

    | +--------------+ | |

    | | TBL_APPROVER | | |

    | +--------------+ | |

    | | ID_APPROVER |-+--' |

    |----------+<| ID_PERSON | |

    | | (DETAIL) | |

    | +--------------+ |

    | |

    | +-------------+ |

    | | TBL_TEACHER | |

    | +-------------+ |

    | | ID_TEACHER |-+-----'

    '----------+<| ID_PERSON |

    | (DETAIL) |

    +-------------+

  • Hi, thank you for your thoughts, the second diagram is more interesting for me.

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

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