Database - Designing an “Events” Table

前端 未结 3 1232
没有蜡笔的小新
没有蜡笔的小新 2020-12-12 17:39

After reading the tips from this great Nettuts+ article I\'ve come up with a table schema that would separate highly volatile data from other tables subjected to heavy reads

3条回答
  •  我在风中等你
    2020-12-12 17:55

    I highly recommend this approach. Since you're presumably using the same database for OLTP and OLAP, you can gain significant performance benefits by adding in some stars and snowflakes.

    I have a social networking app that is currently at 65 tables. I maintain a single table to track object (blog/post, forum/thread, gallery/album/image, etc) views, another for object recommends, and a third table to summarize insert/update activity in a dozen other tables.

    One thing that I do slightly differently is to maintain an entity_type table, and use its ID in the object_type column (in your case, the 'TABLE' column). You would want to do the same thing with an event_type table.

    Clarifying for Alix - Yes, you maintain a reference table for objects, and a reference table for events (these would be your dimension tables). Your fact table would have the following fields:

    id
    object_id
    event_id
    event_time
    ip_address
    

提交回复
热议问题