Skip site navigation (1) Skip section navigation (2)

Re: can I define a hyperlink as a datatype

From: Oliver Fromme <olli(at)lurza(dot)secnetix(dot)de>
To: josh(at)agliodbs(dot)com
Cc: ps_postgres(at)yahoo(dot)com (Kumar S), pgsql-novice(at)postgresql(dot)org
Subject: Re: can I define a hyperlink as a datatype
Date: 2004-09-15 09:19:28
Message-ID: 200409150919.i8F9JSHf052369@lurza.secnetix.de (view raw or flat)
Thread:
Lists: pgsql-novice
Josh Berkus wrote:
 > Kumar,
 > >  is there a way to define a hyperlink as a datatype.
 > > 
 > > I want to store hyperlink for an FTP site as my data
 > > link. Is this possible or it is good to define it as
 > > varchar.
 > 
 > You can just use TEXT.    If you want to get really sophisticated, you can 
 > define a DOMAIN to check for proper format.

Depending on the application, it might also be useful to
store the components of the URI in separate columns, i.e.
method, hostname, username/password, port number, path,
arguments and anchor (most of those are optional).

For example, http://www.freebsd.org/cgi/man.cgi?query=ls
would be stored like this:  method = 'http', hostname =
"www.freebsd.org", username = NULL, password = NULL, port =
80, path = "/cgi/man.cgi", arguments = "query=ls", anchor =
NULL.

Then you can, for example, sort and select by hostname,
compare document URIs without regard to arguments and an-
chors, more easily search for specific path names, etc.

Of course, if the application handles the URIs as opaque
strings without being interested in their components, then
storing them as single TEXT values is sufficient.

(BTW, varchar(n) would be a bad idea, because they can get
pretty long.  Earlier RFCs define a limit of 1023 chars,
however, that limit was lifted by later standards, IIRC.)

Best regards
   Oliver

-- 
Oliver Fromme, secnetix GmbH & Co KG, Oettingenstr. 2, 80538 M√ľnchen
Any opinions expressed in this message may be personal to the author
and may not necessarily reflect the opinions of secnetix in any way.

"And believe me, as a C++ programmer, I don't hesitate to question
the decisions of language designers.  After a decent amount of C++
exposure, Python's flaws seem ridiculously small." -- Ville Vainio

In response to

pgsql-novice by date

Next:From: Arthur van DorpDate: 2004-09-15 13:46:15
Subject: Re: can I define a hyperlink as a datatype
Previous:From: Josh BerkusDate: 2004-09-14 23:18:18
Subject: Re: can I define a hyperlink as a datatype

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group