tetherless-world / mcs-apps

DARPA Machine Common Sense (MCS) applications for exploring knowledge graphs of common sense, benchmark questions, and question-answering processes
MIT License
4 stars 1 forks source link

PostgreSQL store implementation #263

Closed 123joshuawu closed 3 years ago

123joshuawu commented 3 years ago

@gordom6 I'd like to get your feedback on the schema before moving on

Here is a visual of what the relationships look like to help with review Screen Shot 2020-10-26 at 2 44 34 AM

123joshuawu commented 3 years ago

If this is not missing anything then I will begin implementing the PostgresCommandStore

Updated diagram: https://dbdesigner.page.link/GQ3U7bmCH6nfy7oi9 Screen Shot 2020-10-27 at 2 17 21 AM

gordom6 commented 3 years ago

Use text instead of varchar(n), there's no reason to limit the length of those fields. I assume text can still be a primary key.

page_rank should be real (aka float4), those don't need 8-byte precision.

It'd be nice to have some marker of the join tables, since the names can get awkward. I've used _x_ in the past, as in kg_node_x_kg_source. (You currently call it kg_edge_source, which is inconsistent with the other join table names.)

You could probably dispense with the kg prefixes entirely. We need them in the code because it's shared with the benchmark app, but the neo4j store doesn't use kg prefixes in its naming.

123joshuawu commented 3 years ago

I thought VARCHAR(254) was the default mapping for String but it turns out TEXT is the default for Postgres

123joshuawu commented 3 years ago

@gordom6 am stuck on this error when I try to run sbt "project kgApp" -DkgStore=postgres run, seems like my @Inject for the postgres config is not working but not sure why

CreationException: Unable to create injector, see the following errors:

1) Error injecting constructor, java.lang.NullPointerException
  at io.github.tetherlessworld.mcsapps.lib.kg.stores.postgres.PostgresKgCommandStore.<init>(PostgresKgCommandStore.scala:16)
  at io.github.tetherlessworld.mcsapps.lib.kg.stores.postgres.PostgresKgCommandStore.class(PostgresKgCommandStore.scala:16)
  while locating io.github.tetherlessworld.mcsapps.lib.kg.stores.postgres.PostgresKgCommandStore
  while locating io.github.tetherlessworld.mcsapps.lib.kg.stores.KgCommandStore
    for the 2nd parameter of io.github.tetherlessworld.mcsapps.lib.kg.stores.KgDataDirectoryLoader.<init>(KgDataDirectoryLoader.scala:24)
  at io.github.tetherlessworld.mcsapps.lib.kg.stores.KgStoresModule.configure(KgStoresModule.scala:44) (via modules: com.google.inject.util.Modules$OverrideModule -> stores.KgStoresModule -> io.github.tetherlessworld.mcsapps.lib.kg.stores.KgStoresModule)
  while locating io.github.tetherlessworld.mcsapps.lib.kg.stores.KgDataDirectoryLoader
123joshuawu commented 3 years ago

@gordom6 I think this wraps up the current pr. The command store should be complete, I will implement the remaining query store methods in the subsequent two prs in the following order: 1) PageRank

I'd like to get your review on the current state, then I will merge master into this branch to update the docker compose

123joshuawu commented 3 years ago

@gordom6 Yes, the test failures are due to the missing fulltext and pageRank