Question about the `CREATE PROPERTY GRAPH` statement
sleepymole opened this issue · 2 comments
I'm reading PGQL 1.4 Specification. I have some questions about the CREATE PROPERTY GRAPH
statement.
In the specification, we can specify the keys in the CREATE PROPERTY GRAPH
statement itself. An example is:
CREATE PROPERTY GRAPH financial_transactions
VERTEX TABLES (
Accounts
KEY ( number )
LABEL Account
PROPERTIES ( number ),
...
)
EDGE TABLES (
Transactions
SOURCE KEY ( from_account ) REFERENCES Accounts
DESTINATION KEY ( to_account ) REFERENCES Accounts
LABEL transaction PROPERTIES ( amount ),
Accounts AS PersonOwner
SOURCE KEY ( number ) REFERENCES Accounts
DESTINATION Persons
LABEL owner NO PROPERTIES,
...
)
I want to know which key in vertex table does the edge table PersonOwner
's source key actually reference?
My understanding is it will reference the key explicitly defined in vertex table first. If the key clause is missing in vertex table, it will try to references the underlying primary key.
In addition, if two vertex table use the same underlying table, at least one table name need to be aliased. In this case, do we need to use the aliased table name in edge table's definition?
My understanding is it will reference the key explicitly defined in vertex table first. If the key clause is missing in vertex table, it will try to references the underlying primary key.
You're right, that's how it works.
In addition, if two vertex table use the same underlying table, at least one table name need to be aliased. In this case, do we need to use the aliased table name in edge table's definition?
Yes you would indeed need to use the alias in the edge table's definition. If no alias is specified, the alias defaults to the table name without the schema part (i.e. my_schema.my_table
translates to my_schema.my_table AS my_table
).
@oskar-van-rest I got it, thank you very much for your reply!