How to create friendly identifier / user friendly triples?

Jul 18, 2014 at 3:31 PM
Edited Jul 18, 2014 at 3:33 PM
Hi there,

I need at create a rdf database, similarly to dbpedia. So the user can run simple sparql queries like:
SELECT DISTINCT res:London ?p ?o
  res:London ?p ?o .
To get all the london triples.

BSDB use uuid as identifier, so the user won't be able to access a simple ~/London page to get all the London triples.
  1. Is there a way to override the auto generated identifier?
  2. Is there a way to create a view (like sql view) of the graph, that takes all the ids of names (or any other friendly identifier) , and then replace the id with that name-or-friendly-identifier?
so if you have three triples in the db:


the view will look as follows:

So the view picks the name from the 'name-or-friendly-identifier triple, and replace the id of all the triples of that id with the name-or-friendly-identifier.

Any other suggestion of how to provide friendly and readable triples are welcome.

Jul 20, 2014 at 7:23 AM
Edited Jul 20, 2014 at 8:20 AM

I have changed in the AssemblyInfo.cs :
[assembly: TypeIdentifierPrefix("http://db/")]
Jul 20, 2014 at 4:10 PM
You can override the default GUID id in one of two ways:

1) You can use the Add() overload that allows you to specify an ID:
    var london = new City();
    myContext.City.Add(london, "");
2) You can set the Id property on the entity before connecting it to the context.
    var london = new City { Id="London" };
In either case you should also make sure that you map the type and identifier prefixes in your ICity interface:
public interface ICity {
  public string Id {get;}
  ... other properties here - use [PropertyType("http://...")] to map properties to the correct URI
Jul 21, 2014 at 9:01 AM
Great, thanks a lot! I will try that.

Just a quick question. Are there any best practices of how to make sure the id is unique when using brightstarDB? There are no unique constraints, right? so does it all have to come from the application?

Jul 29, 2014 at 12:56 PM
Actually I've been working on adding unique constraints - the next version of BrightstarDB will support this if you use the BrightstarDB backend - unfortunately SPARQL doesn't provide the mechanisms we would need to support this over SPARQL UPDATE.

The code is in the develop branch right now and I've updated the develop branch of the documentation. You can read more there about key properties and composite keys and about using these keys in key constraints.


Jul 29, 2014 at 1:20 PM
Great, Thank you!