dqrmkdu25623 2012-04-12 13:47
浏览 39
已采纳

mysql中的多维表

Is it possible to have a multi-dimensional table in mySQL

I want to log users based on based on their ip, their user-agent and the session token they sent.

Something like this:

ip1
    user-agent1
        session token1
    user-agent2
        session token2
        session token3
ip2
    user-agent3
        session token4

I would like to avoid using serialize() as I've heard it would make the table less efficient and less portable.

  • 写回答

1条回答 默认 最新

  • dongni1892 2012-04-12 13:53
    关注

    It isn't that you have a multi-dimensional table, but rather multiple tables.

    Table ips

    id INT
    ip VARCHAR
    

    Table useragents (links UA to IP)

    ip_id INT
    useragent VARCHAR(2048) (some large value)
    

    Table tokens (links users to tokens)

    id
    userid 
    token
    

    All three of the components above are linked together via their id columns into a table identifying sessions. Multiple ip_id may associate with a single token, which in turn associates multiple possible UA strings.

    It leaves the possibility that there can be identical UA strings for the same IP, but with multiple different session tokens from that same IP.

    Table sessions

    ip_id
    token_id
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥15 可见光定位matlab仿真