ConnectedDataLondon
11 views
26 slides
Oct 10, 2017
Slide 1 of 26
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
About This Presentation
A Triple Store for .NET Developers
Size: 195.81 KB
Language: en
Added: Oct 10, 2017
Slides: 26 pages
Slide Content
BrightstarDB A Triple Store for .NET Developers @ brightstardb
About Me… .NET developer and standards geek Background in XML, ISO Topic Maps and RDF Co-founded Networked Planet in 2014 Involved in O/S projects combining .NET and RDF dotNetRDF Quince BrightstarDB
About NetworkedPlanet Small ISV and consultancy Linked Data, RDF, ISO Topic Maps Data Platform Linked Dataset Publishing http://dataplatform.co.uk/ DataDock Free CSV to Linked Open Data Solution http://datadock.io/
BrightstarDB in a Nutshell “Native” .NET Triple Store Built on dotNetRDF Run embedded or as a server Cross-platform Transactional .NET Developer-friendly Open Source, MIT-Licensed
Standards Support Wide variety of RDF syntaxes NTriples / NQuads Turtle/ TriG TriX RDF/XML SPARQL 1.1 Query Update Graph Store Protocol
Embedded Server Option Small footprint (~4MB) Available as NuGet Packages Zero-configuration
RESTful Server Option Run as a command-line or Windows Service RESTful API Simple browser-based GUI Embedded client/server is a connection string edit
Cross-Platform Currently: .NET 4.0+ .NET Portable Profile 344 (.NET 4.5, SL 5, Windows 8, WPA 8.1, WP8) Android & iOS via Xamarin Plan: Unify as much as possible under .NET Core Database file format is also cross-platform
Store Features Transactional Updates Delete, Insert Conditional Updates Must Exist, Must Not Exist, Delete, Insert Append-only store Persistent History Cloning/Branching Writers don’t block readers (and vice-versa) Transaction History
GUI Tool WPF Application Create / Delete Stores Import / Export Data Run SPARQL Queries & Update
Architecture Append-Only Store Rewrite Store Any SPARQL 1.1 Endpoint SPARQL Engine Data Objects API Dynamics API B* Entity Framework API
Data Objects API Abstraction of a resource-oriented view of the RDF graph Properties are lazily-loaded from the server as the graph is traversed Updates are a collection of triples to add and to delete on SaveChanges Option to use optimistic locking for updates Store Operations: MakeDataObject ( iri_or_curie ) GetDataObject ( iri_or_curie ) ExecuteSparql ( sparql_query ) BindDataObjectsWithSparql ( sparql_query ) SaveChanges () DataObjectOperations : Get/Set/Add/ RemoveType (type) Get/Set/Add/ RemoveProperty ( property_type , property_value )
Dynamics API Treats RDF resources as a dynamic object with typed properties Works nicely with Python and F# as well as C# dynamic brightstar = dynaStore.MakeNewObject (); brightstar. rdfs __label = new[] { " BrightstarDB ", "NoSQL Database" }; dynamic product = dynaStore.MakeNewObject (); brightstar. rdfs __type = product;
Contract-First Data Binding [Entity(“ foaf:Person ”)] public interface IPerson { [Property(“ foaf:name ”)] public string Name { get;set ;} [Property(“ foaf:knows ”)] ICollection < IPerson > Friends {get; set;} } IPerson fred = context.Persons.FirstOrDefault ( x=> x.Name.Equals (“Fred”)) IPerson alice = context.Persons.Create (); alice.Name = “Alice”; fred.Friends.Add ( alice ); context.SaveChanges ();
Contract-First Data Binding Define interfaces decorated with properties Run code-generation to generate implementation as C# partial classes Currently code-generation is required at compile-time Option of Text Template or Roslyn-based code generation to support builds outside of Visual Studio/ MSBuild
Runtime Casting Data binding is dynamic Mapping of property accesses to an underlying DataObject Can instantiate a new data-binding for an RDF resource “on the fly” IPerson fred = context.Persons.FirstOrDefault (x=> x.Name == “Fred”); IMusician musoFred = fred.As < IMusician >();
LINQ-to-SPARQL LINQ – Language Integrated Query var results = from p in context.Persons where p.Name == “Fred” select p; LINQ converted to a SPARQL query using the data binding contract SPARQL executed against the backend Results bound to .NET instances or anonymous objects Read from any SPARQL 1.1 query endpoint Write to any SPARQL 1.1 update endpoint No SPARQLfu required!
LINQ to SPARQL: Select by ID from p in Context.Dinners select p.Id SELECT ?p WHERE { ?p a <http://nerddiner.com/schema/Dinner> . }
LINQ to SPARQL: Get Related Properties from p in Context.Dinners where p.Id.Equals ("1") select p.Rsvps ; SELECT ?v0 WHERE { <http://nerddinner.com/dinners/1> a <http://nerddinner.com/schema/Dinner> . <http://nerddinner.com/dinners/1> <http://nerddinner.com/schema/attendees> ?v0 . }
LINQ to SPARQL: Simple Join from x in Context.Dinners from r in x.Rsvps select r.AttendeeEmail SELECT ?v1 WHERE { ?x a <http://nerddinner.com/schema/Dinner> . ?r a <http://nerddinner.com/schema/Rsvp> . ?x <http://nerddinner.com/schema/attendees> ?r . ?r <http://nerddinner.com/schema/email> ?v1 . }
LINQ to SPARQL: Filters from x in Context.Dinners where x.EventDate >= DateTime.UtcNow select x.Id SELECT ?x WHERE { ?x a <http://nerddinner.com/schema/Dinner> . ?x <http://nerddinner.com/schema/eventDate> ?v0 . FILTER (?v0 >= '2014-03-05T16:13:25Z'^^<http://www.w3.org/2001/XMLSchema#dateTime>) . }
LINQ to SPARQL: Anonymous Objects var q = from x in Context.Dinners select new { x.Title , x.EventDate }; SELECT ?v0 ?v1 WHERE { ?x a <http://nerddinner.com/schema/Dinner> . OPTIONAL { ?x <http://nerddinner.com/schema/title> ?v0 . } OPTIONAL { ?x <http://nerddinner.com/schema/eventDate> ?v1 .} }
LINQ to SPARQL – Eager Loading Uses SPARQL CONSTRUCT and SPARQL 1.1 subqueries Basic pattern: CONSTRUCT { ?s ?p ?o } WHERE { ?s ?p ?o . SELECT ?s WHERE { … } } Refinements required to account for sorting and paging Unpaged queries are sorted on the client Paged queries have to be sorted on the server and the page sorted again on the client
B*EF vs Relational Data Binding No tables So no messy migration scripts Data binding as view A Resource can have multiple types Each type can be bound to a different .NET interface Application can use the interface(s) that it requires Application can dynamically switch between interfaces as needed
Future Plans .NET Core support NETStandard 1.4 (drop Windows Phone and Silverlight support) iOS, Mac, Android and Linux will still be supported Performance and scaling Aim to match Apache Jena on desktop/server hardware Reduce memory usage (esp. on Android/iOS) Considering replacing current persistence layers with a single hybrid format Replication for scaling and / or redundancy Sharding for horizontal scaling Update Code Generation Unify on a single code-generation framework Add support for runtime code generation