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
Views: Raw Message | Whole Thread | Download mbox | Resend email
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

Browse pgsql-novice by date

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