What is URI
A URI identifies a resource either by location, or a name, or both. More often than not, most of us use URIs that defines a location to a resource. The fact that a URI can identify a resources by both name and location has lead to a lot of the confusion in my opinion. A URI has two specializations known as URL and URN.
What is URN
A URI identifies a resource by name in a given namespace but not define how the resource maybe obtained. This type of URI is called
a URN. You may see URNs used in XML Schema documents to define a namespace, usually using some syntax.
And finnaly what is URL
A URL is a specialization of URI that defines the network location of a specific resource. Unlike a URN, the URL defines how the resource can be obtained. We use URLs every day in the form of http://exemple.com, etc. But a URL doesn’t have to be an HTTP URL, it can be ftp://example.com, smb://example.com, etc.
Here is a diagram that shows the relationship between the three terms.
Here are some examples so you can understand it better.
All of these Examples are URIs:
|Examples of URLs:||
mailto:email@example.com http://www.damnhandy.com/ https://github.com/afs/TDB-BDB.git file:///home/someuser/somefile.txt
|Examples of URNs:||
urn:mpeg:mpeg7:schema:2001urn:isbn:0451450523 urn:sha1:YNCKHTQCWBTRNJIV4WNAE52SJUQCZO5C urn:uuid:6e8bc430-9c3a-11d9-9669-0800200c9a66
Again, all of the examples above are all valid examples of URIs. You’ll note of course that all of the URNs are prefixed with “urn:”.
Hope that this was useful to you.