图结构数据库和 Php

发布于 2024-09-02 08:28:15 字数 828 浏览 7 评论 0原文

我想使用 php 来使用图形数据库。您能指出一些从哪里开始的资源吗?有没有示例代码/教程?或者是否有其他方法可以在完全随机/抽象的情况下存储彼此相关的数据?

-

所需关系的非常抽象的示例:约翰与玛丽相关,两者都与学校相关,约翰高,玛丽矮,约翰有蓝眼睛,玛丽有绿眼睛,我想要的查询是哪些人与“矮个子”相关有绿眼睛去上学' ->回答 John

-

另一个例子:

    TrackA -> ArtistA
           -> ArtistB

           -> AlbumA -----> [ label ]
           -> AlbumB -----> [   A   ]

           -> TrackA:Remix
           -> Genre:House

           -> [ Album ] -----> [ label ]
   TrackB  -> [   C   ]        [   B   ]

示例查询:

TrackB 更接近哪种流派?答案:House - 因为它与专辑 C 相关,而专辑 C 与 TrackA 相关且与 Genre:House

相关 获取标签 A 的所有与 Genre:House 相关的专辑:结果:AlbumA、AlbumB - 因为它们都有与 Genre 相关的 TrackA :House

-

这在 MySQL 中是可能的,但它需要每个项目有一组固定的属性/列和一个复杂的非灵活查询,相反,我需要每个属性本身就是一个项目,而不是“属于”某个东西,与某事“相关”。

I want to use a graph database using php. Can you point out some resources on where to get started? Is there any example code / tutorial out there? Or are there any other methods of storing data that relate to each other in totally random/abstract situations?

-

Very abstract example of the relations needed: John relates to Mary, both relate to School, John is Tall, Mary is Short, John has Blue Eyes, Mary has Green Eyes, query I want is which people are related to 'Short people that have Green Eyes and go to School' -> answer John

-

Another example:

    TrackA -> ArtistA
           -> ArtistB

           -> AlbumA -----> [ label ]
           -> AlbumB -----> [   A   ]

           -> TrackA:Remix
           -> Genre:House

           -> [ Album ] -----> [ label ]
   TrackB  -> [   C   ]        [   B   ]

Example queries:

Which Genre is TrackB closer to? answer: House - because it's related to Album C, which is related to TrackA and is related to Genre:House

Get all Genre:House related albums of Label A : result: AlbumA, AlbumB - because they both have TrackA which is related to Genre:House

-

It is possible in MySQL but it would require a fixed set of attributes/columns for each item and a complex non-flexible query, instead I need every attribute to be an item by itself and instead of 'belonging' to something, to be 'related' to something.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

三岁铭 2024-09-09 08:28:16

另请参阅这篇有关在 PHP 中使用 OrientDB 的文章: http://www.odino.org/346/orientdb-the-graph-db-for-the-web

Take also a look to this article about the usage of OrientDB with PHP: http://www.odino.org/346/orientdb-the-graph-db-for-the-web

山有枢 2024-09-09 08:28:16

您还可以找到 php 的 Rexster 客户端:https://github.com/PommeVerte/rexpro-php

作为额外信息。 Rexster 可以从各种其他图形数据库(例如 Neo4j 和 OrientDb 等)加载图形。

You can also find a Rexster client for php : https://github.com/PommeVerte/rexpro-php

As extra information. Rexster can load graphs from various other graph dbs such as Neo4j and OrientDb among others.

悟红尘 2024-09-09 08:28:15

目前正在开展一些工作,使 PHP 可以使用 Neo4j 图形数据库,请参阅 此 wiki 页面 了解更多信息!关于如何将域建模为图表,用户邮件列表往往非常棒。

更新:现在有一个简短的入门PHP neo4j REST 客户端的博客文章

There's some work going on to make the Neo4j graph database available from PHP, see this wiki page for more information! Regarding how to model your domain as a graph, the user mailing list tends to be pretty awesome.

Update: there's now a short getting started blog post for a PHP neo4j REST client.

无敌元气妹 2024-09-09 08:28:15

对我来说听起来有点像一个“典型的”Prolog 问题......这是一个相当与 PHP 不同的编程语言。但也许你可以和 popen 一起工作。

或者定义一个包含列 [ id, predicate,atom1,atom2 ] 的 SQL 表,来存储“Mary has Green Eyes”的真实性:predicate = “has”,atom1 =“Mary”,atom2 =“Green Eyes”。

现在您可以使用您选择的 SQL 连接和过滤谓词和属性。

Sounds to me a little bit like a "typical" Prolog problem... which is a quite different programming language than PHP. But perhaps you could work with popen.

Or you define an SQL table with columns [ id, predicate, atom1, atom2 ], to store the truthness of "Mary has Green Eyes": predicate = "has", atom1 = "Mary", atom2 = "Green Eyes".

Now you could join and filter the predicates and attributes with the SQL of your choice.

呆橘 2024-09-09 08:28:15

它看起来像一个语义网络问题。因此,您必须弄清楚如何将 PHP 和语义网结合使用。也许这个链接 http://bnode.org/blog/2009/05/25/back-from-new-york-semantic-web-for-php-developers-trip 可以帮忙吗?

It looks like a semantic web problem. So you have to figure out how you can use PHP and the semantic web together. Maybe this link http://bnode.org/blog/2009/05/25/back-from-new-york-semantic-web-for-php-developers-trip can help?

少钕鈤記 2024-09-09 08:28:15

听起来您应该这样处理:

1)编写一个图形对象,让您可以按照自己想要的方式查询数据。

2) 为您的对象编写持久层

3) 优化在图形对象中执行查询的调用,以在适当时使用数据库调用(例如,如果您需要节省内存)。

It kind of sounds like you should approach it this way:

1) Code a graph object that will let you query your data the way you want.

2) Write a persistence layer for your object

3) optimize the calls that do your query's in the graph object to use database calls when appropriate (for example, if you need to conserve memory).

昵称有卵用 2024-09-09 08:28:15

我的建议是选择基于 Java 的图形数据库,例如 OrientDB 或 neo4j,然后通过 PHP 使用它/Java 桥。在不久的将来,neo4j(以及在某些时候 OrientDB)应该获得本机 php 支持,并且您可以用本机访问替换桥。

My suggestion is to pick a Java-based graph DB like OrientDB or neo4j and then use it via the PHP/Java bridge. In the near future neo4j (and at some point OrientDB as well) should get native php support and you can replace the bridge with native access.

聊慰 2024-09-09 08:28:15

考虑到这个问题已经存在一年了,注意到您可以对每个支持 sparql 或类似语言的 rdf 数据存储进行这样的查询可能仍然很有趣。

well taking into account this question is one year old, it might still be interesting to note that you can do such a query with every rdf datastore that supports sparql or comparable languages.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文