我有2个班级,1个用于药品,另一个用于月度交易。 药物结构:
Create class Medicines extends V
Create property Medicines.medicine_id integer
Create property Medicines.medicine_Brand integer
Create property Medicines.medicine_Code String
每月转化的结构:
Create class Transactions extends V
Create property Transactions.transaction_id integer
Create property Transactions.transaction_Date Date
Create property Transactions. transaction _medicine_id Integer
现在,我希望创建一个边缘,来自" Transactions.transaction _medicine_id" to" Medicines.medicine_Code" 。如果是RDBMS,我会在“事务”之间建立关系。 transaction _medicine_Code“AND”Medicines.medicine_id“但是在图形数据库中我们不能创建字段之间的关系,所以我应该如何在这些字段之间创建边缘。
药物:
----+-----+---------+-----------+-------------
# |@RID |@CLASS |medicine_id|medicine_Code
----+-----+---------+-----------+-------------
0 |#15:0|Medicines|1 |abc
1 |#15:1|Medicines|2 |xyz
----+-----+---------+-----------+-------------
交易:
----+-----+------------+--------------+-------------------+-----------------------
# |@RID |@CLASS |transaction_id|transaction_Date |transaction_medicine_id
----+-----+------------+--------------+-------------------+-----------------------
0 |#16:0|Transactions|1 |2016-01-12 00:00:00|1
1 |#16:1|Transactions|2 |2016-01-12 00:00:00|2
----+-----+------------+--------------+-------------------+---------------------
-
我想要的是像
这样的输出----+-----+------------+--------------+-------------------+-----------------------
# |@RID |@CLASS |transaction_id|transaction_Date |transaction_medicine_Code|
----+-----+------------+--------------+-------------------+-----------------------
0 |#16:0|Transactions|1 |2016-01-12 00:00:00|abc
1 |#16:1|Transactions|2 |2016-01-12 00:00:00|xyz
----+-----+------------+--------------+-------------------+---------------------
-
答案 0 :(得分:3)
在我看来,你需要考虑更多的图形数据库导向,所以删除外键并建立关系创建边缘b / w药物rids和交易rids。
----------- sell --------------
|Medicines| -----------------> |Transactions|
----------- --------------
Create class Medicines extends V
Create property Medicines.medicine_Brand String
Create property Medicines.medicine_Code Integer
Create class Transactions extends V
Create property Transactions.transaction_id integer
Create property Transactions.transaction_Date Date
Create class sell extends E
然后获取请求的输出:
SELECT transaction_id, transaction_Date, in('sell').medicine_Code FROM Transactions