Nice link. I followed the
Tag Spec so all the id's I've been generating are extremely similar to what Mark is suggesting. For BlogSvc, the design can support integer primary keys if that is what the database needs to have. The repository can alter the Id of an entry when it gets created (doesn't ever change after that). Therefore, you could potentially have something similar to what Mark suggests for the timestamp:
Example:
tag:blogsvc.net,2008-08-19:blog,20080819110347
This would make a composite key of workspace, date, collection, entryNum. However, it wouldn't translate well into a pretty url. You could also do something like:
tag:blogsvc.net,2008-08-19:blog,101-MyEntry
where you could extract the integer id and it would look better translated to a permalink. The other two options are
- Allow permalinks to change (disconnect id from permalink)
- Use urn:uid:guid syntax which is fairly popular but not human friendly.
For 1, BlogSvc currently translates Urls (both permalinks and atom links) into Ids for talking to the repository. If the permalinks were to differ from the id, we must use the link to lookup the id to lookup the post. This isn't much of a problem for a database but for the file system repository you'd need to build some sort of index or restructure based on permalink. The goal with the usage of the tag scheme is to create an internally dereferencable value that we can use build logic around the workspace, collection, and entry. We could create an implementation of the following interface to support non-dereferencable ids.
public interface IRouteService
{
AppService AppService { get; set; }
Id IdFromNames(string workspace, string collection, string date, string entryPath);
Id IdFromNames(string workspace, string collection, string entryPath);
Id IdFromNames(string workspace, string collection);
Id IdFromPath(string path);
Id IdFromPath(string workspace, string path);
Id IdFromPath(string workspace, string collection, string path);
Uri IdToAtomHref(Id id);
Uri IdToMediaHref(Id id);
Uri IdToWebHref(Id id);
Uri ServiceHref();
}