dqx76962 2012-05-21 14:19
浏览 43
已采纳

更正用户表关系的正确方法?

I am working on an event system that has two tables, EVENTS and EVENT_CREATORS. I have been linking events to creators by placing creator id in the events table as I thought I would only ever have one event creator.

I now need the ability for more than one creator to edit an event. Should I add simply add additional fields to EVENTS table, i.e ec_id, ec_id_2, ec_id_3, etc. Or does it make more sense to add a cross reference table to the database and a separate table for additional creators?

  • 写回答

3条回答 默认 最新

  • duandingqi9442 2012-05-21 14:32
    关注

    This is those cases, where it would be wise to use a cross reference table. I will explain it step by step. First

    • Create a new table. Call it "event_reference"
    • Give the following FIelds: Id, Ref_Id, Creator_ID.

    I will omit the need of the EventId, because we are creating a table which is a reference to the event, so event's table will hold the Ref_Id to keep in track of all the references.

    • Next, Modify the events table and store Ref_ID instead of Creator

    In such way, you can fetch all the creators of an events in the normalized way.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部