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
WHERE {
  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:
http:///www.mydomain.com/cities/e41ffd64-1567-46ec-b010-d29978d2a74a
http://www.mydomain.com/types/name-or-friendly-identifier   
London

http:///www.mydomain.com/cities/e41ffd64-1567-46ec-b010-d29978d2a74a
rdf:type 
http://schema.org/City

http:///www.mydomain.com/cities/e41ffd64-1567-46ec-b010-d29978d2a74a
foaf:homepage 
http://www.london.gov.uk/
the view will look as follows:
http:///www.mydomain.com/cities/London
rdf:type 
http://schema.org/City

http:///www.mydomain.com/cities/London
foaf:homepage 
http://www.london.gov.uk/
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.

Thanks!
Jul 20, 2014 at 7:23 AM
Edited Jul 20, 2014 at 8:20 AM
Hello,

I have changed in the AssemblyInfo.cs :
[assembly: TypeIdentifierPrefix("http://db/")]
Regards
Coordinator
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, "http://www.mydomain.com/citites/London");
2) You can set the Id property on the entity before connecting it to the context.
    var london = new City { Id="London" };
    myContext.City.Add(london);
In either case you should also make sure that you map the type and identifier prefixes in your ICity interface:
[Entity("http://schema.org/City")]
public interface ICity {
  [Identifier("http://www.mydomain.com/cities/")]
  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?

Thanks!
Coordinator
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 readthedocs.org documentation. You can read more there about key properties and composite keys and about using these keys in key constraints.

Cheers

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