This repository holds the GraphQL schema and RDF file needed to setup a Shakespeare database on Slash.
This project is split across 2 repositories:
- dgraph-shakespeare-data (current repository): Contains the RDF file and GraphQL schema needed to setup DGraph.
- complete-shakespeare: Contains code for Alexa skill for Shakespeare which consumes data from DGraph.
-
Set the backend mode to flexible and generate an admin API key.
-
Copy schema from
schema.graphql
and save it in the Slash console. -
Upload
sql.rdf
to Slash using live loader. The command should have the absolute path to this folder.docker run -it --rm -v /path/to/dgraph-shakespeare-data/sql.rdf:/tmp/sql.rdf dgraph/dgraph:v20.07-slash \ dgraph live --slash_grpc_endpoint=<grpc-endpoint>:443 -f /tmp/sql.rdf -t <api-token>
These steps are for documentatary purposes. The final schema.graphql
and sql.rdf
files have already been prepared.
-
Run a MySQL instance on localhost using XAMPP and PHPMyAdmin.
-
Create new database and import data from
shakespeare.sql
. This is an improved version of the dump provided by Open Source Shakespeare. Unnecessary tables were removed, fields were renamed and foreign keys were added. -
Run the SQL to Dgraph migration tool to obtain
schema.txt
andsql.rdf
files. Add necessary credentials inconfig.properties
file.dgraph migrate --config config.properties --output_schema schema.txt --output_data sql.rdf --host 192.168.64.2
-
By looking at the database, design a
schema.graphql
file as per needs. Add types, authorization, inverse relations and search as necessary. -
Some regular expression transformations were performed on the generated
sql.rdf
file to support all access patterns- adding<dgraph.type>
, reverse relations etc. For complete steps, look at my blog post.
- In the SQL data, Paragraph table does not have a foreign key for Chapter table.
Paragraph
andChapter
graphQL types are yet to be linked. Quotes
table was separate and not linked toWorks
,Character
or any other table. The graphQL types are not linked yet.
- Open source Shakespeare by George Mason University: For making their SQL database open source.
- Terence Eden and Richard Morrison: For improvements in the original SQL dump.
- DGraph Labs and DGraph developer community