문제

I will make an application with a lot of similar items (millions), and I would like to store them in a MySQL database, because I would like to do a lot of statistics and search on specific values for specific columns.

But at the same time, I will store relations between all the items, that are related in many connected binary-tree-like structures (transitive closure), and relation databases are not good at that kind of structures, so I would like to store all relations in Neo4j which have good performance for this kind of data.

My plan is to have all data except the relations in the MySQL database and all relations with item_id stored in the Neo4j database. When I want to lookup a tree, I first search the Neo4j for all the item_id:s in the tree, then I search the MySQL-database for all the specified items in a query that would look like:

SELECT * FROM items WHERE item_id = 45 OR item_id = 345435 OR item_id = 343 OR item_id = 78 OR item_id = 4522 OR item_id = 676 OR item_id = 443 OR item_id = 4255 OR item_id = 4345

Is this a good idea, or am I very wrong? I haven't used graph-databases before. Are there any better approaches to my problem? How would the MySQL-query perform in this case?

도움이 되었습니까?

해결책

이 작업을 수행하려면 Java 스크립트가 필요합니다. 샘플 스크립트가 있습니다. 수정해야합니다.

<script type="text/javascript">
var tables = document.getElementsByTagName('table');
for (var i=0; i<tables.length; i++)
{
if (tables[i].summary == 'Rating Scale Question')
{
var trs = tables[i].getElementsByTagName('tr'); 
var tds = trs[0].getElementsByTagName('td'); 
tds[2].colSpan = 1;
tds[2].innerHTML = 'your range text';
tds[3].colSpan = 1;
tds[3].innerHTML = 'your range text';
tds[4].colSpan = 1;
tds[4].innerHTML = 'your range text';
tds[5].colSpan = 1;
tds[5].innerHTML = 'your range text'; 
tds[6].colSpan = 1;
tds[6].innerHTML = 'your range text'; 
}
}
</script>
.

http://social.technet.microsoft.com/forums/sharepoint/en-us/dd6fa536-0cd8-4985-9926-f5a695adbce/add-new-평가 - 스케일 텍스트 - 인-SharePoint Survey? 포럼= SharePointGeneralPrevious

다른 팁

Relational databases can handle graph structures. Some of them can even handle them moderately elegantly (as elegantly as a relational database gets!).

The key to general graph handling in relational databases is the recursive common table expression (RCTE), which basically lets you iteratively (not recursively, despite the name) expand a query over a set of rows, by combining a query which selects a root set of rows and a query which defines the neighbours of rows selected so far. The syntax is a bit clunky, but it's general and powerful.

RCTEs are supported in PostgreSQL, Firebird, SQL Server, and apparently in DB2. Oracle has a different but equivalent construct; i have read that recent versions support proper RCTEs. MySQL does not support RCTEs. If you aren't wedded to MySQL, i would urge you to consider using PostgreSQL, which is basically a much better database all round.

However, it sounds like you don't need to support general graphs, just trees. In that case, there are more specific options open to you.

One is the classic but rather mindbending nested sets.

A simpler one is to store a path with each row: this is a string which represents the row's position in the tree, and has the property that the path for a node is a prefix of the path for any subnode, which lets you very efficiently do various queries about ancestry ("is node A a child of node B?", "what is node A and node B's lowest common ancestor?", etc). For example, you could construct a path for a row by walking the tree from the root, and joining the IDs of the rows encountered on the way with slashes. This is simple to construct, but does take care to maintain if you rearrange the tree. With a path column, you can restrict a query to a given tree simply by adding and path like '23/%', where 23 is the root's ID.

So, although a graph database is probably the best way to store and query graph data, it is not the only option, and i would suggest you weigh the advantages of using one against the advantages of having all your data in a single database.

I'm mostly with Binary Nerd on this, but would like to add a variation. You could store the live data in Neo4j and then extract the data you need for statistics/reporting and put into MySQL. For searches I'd go with the Neo4j-Lucene integration if that fits your needs.

(+=)를 추가합니다.도트를 사용하여 문자열을 연결하려고합니다.

$filename .= $chars[mt_rand(0, 36)];

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top