简体   繁体   English

neo4j中的数据建模

[英]data modeling in neo4j

i'm new to neo4j trying to model a database the database contain 4 table it is in csv format table 1(details of employee) employees( emp_no ,birth_date ,first_name, last_name ,gender, hire_date) 我是Neo4j的新手,试图为数据库建模数据库包含4个表,它是csv格式的表1(雇员的详细信息)employee(emp_no,birth_date,first_name,last_name,gender,hire_date)

table 2(detail about who was maneger of which dept) dept_maneger(emp_no ,dept_no ,from_date, to_date) 表2(关于谁是哪个部门的负责人的详细信息)dept_maneger(emp_no,dept_no,from_date,to_date)

table 3 (detail about department) departments(dept_no, dept_name) 表3(有关部门的详细信息)部门(dept_no,dept_name)

table 4(detail about which employe belongs to which dept) dept_emp(emp_no ,dept_no ,from_date ,to_date) 表4(关于哪个雇员属于哪个部门的详细信息)dept_emp(emp_no,dept_no,from_date,to_date)

i created the nodes but i want to make a relation ships between department node employee node using from date and to date . 我创建了节点,但我想使用from date和date来建立部门节点员工节点之间的关系。 how can i do that. 我怎样才能做到这一点。

You provided no information about your neo4j data model. 您没有提供有关neo4j数据模型的信息。 Here is an example of simple data model that you could use. 这是您可以使用的简单数据模型的示例。

You can use nodes labelled Employee (for all employees, including managers) and Department . 您可以使用标记为Employee (适用于所有雇员,包括经理)和Department节点。 For example: 例如:

(e:Employee {id: 987, birthdate: 222, firstName: 'Fred', lastName: 'Smith', gender: 'male', hired: 12})
(manager:Employee {id: 221, birthdate: 111, firstName: 'George', lastName: 'Jones', gender: 'male', hired: 10})
(d:Department {id: 324, name: 'Accounting'})

Here are examples of relationships (with the type WORKS_IN ): 以下是关系的示例(类型为WORKS_IN ):

(e)-[:WORKS_IN {from: 123, to: 456}]->(d)
(manager)-[:WORKS_IN {from: 234, to: 567, isManager: true}]->(d)

The start and end dates for all positions are stored in the WORKS_IN relationships. 所有职位的开始和结束日期都存储在WORKS_IN关系中。 If a person works for the same department as a non-manager and then becomes a manager, s/he would have a new WORKS_IN relationship added with the isManager=true property (and the date of the promotion as the from value). 如果某人与非经理在同一部门工作,然后成为经理,则他/她将添加一个新的WORKS_IN关系,并添加isManager=true属性(促销日期为from值)。

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

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