简体   繁体   English

在关系数据库中存储traceroute数据

[英]Storing traceroute data within a relational database

Please ask for clarification if what I am saying doesn't make sense. 如果我说的话没有道理,请要求澄清。

I am attempting to store traceroute data within a relational database, the structure of the traceroute data is as follows: 我正在尝试在关系数据库中存储traceroute数据,traceroute数据的结构如下:

public class Traceroute  
{
    IPAddress origin; 
    IPAddress destination;  
    Collection<Hop> hops;  
}

public class Hop  
{  
     int[] times;  
     IPAddress here;  
     Hop previousHop;
     Hop nextHop;
}  

Now what I am looking for is a relational way to store this data, what ends up happening is my database gets blown out significantly (in theory). 现在,我正在寻找一种存储数据的关系方式,最终发生的是我的数据库严重崩溃(理论上)。 Is there a way to correctly, and by correctly I mean minimal space, to store traceroute data in a relational database and efficiently (quickly) query it? 有没有一种方法可以正确地(并且正确地说是最小的空间)将traceroute数据存储在关系数据库中并高效(快速)查询呢?

THEORETICAL TABLE STRUCTURE 理论表结构

Traceroutes  
(  
    traceroute_id number,
    previousNode varchar2(200), --nullable  
    nextNode varchar2(200), --nullable  
    rtt_1 number,  
    rtt_2 number,  
    rtt_3 number,  
    currentNode varchar2(200)
)  

There's can be no definitive answer to this question. 这个问题不可能有明确的答案。 There are a number of options you could choose. 您可以选择许多选项。 Purely relational you might come up with something like this (this won't compile/run, it's just to demonstrate) 纯粹是关系型的,您可能会想到这样的东西(这不会编译/运行,只是为了演示)

TraceRoute (
    TraceRouteID INTEGER PRIMARY KEY,
    OriginIP NVARCHAR,
    DestinationIP NVARCHAR
)

Hop (
    HopID INTEGER PRIMARY KEY,
    TraceRouteID INTEGER, -- foreign key linking to TraceRoute table PK
    HopNumber INTEGER, -- this instead of storing previus and next nodes
    Time1 INTEGER,
    Time2 INTEGER,
    Time3 INTEGER,
    Host NVARCHAR
)

Notice here you don't need to store where each hop is in relation to each other. 请注意,这里您不需要存储每个跃点相对于彼此的位置。 Every trace route request contains a number of hops which you can order by the hop number. 每个跟踪路由请求都包含许多跃点,您可以按跃点编号对其进行排序。

Next step would be writing queries to extract the information. 下一步将是编写查询以提取信息。 See what the performance is like. 看看表现如何。 If you're not happy then try tuning your database (index columns etc). 如果您不满意,请尝试调整数据库(索引列等)。 If you're still not happy then merge the TraceRoute and Hop tables (sometimes a bit of duplication is OK). 如果您仍然不满意,请合并TraceRoute和Hop表(有时可以进行一些复制)。

Really you need to stop thinking theoretically and actually try it! 确实,您需要停止理论上的思考,然后实际尝试!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM