Re: can I define a hyperlink as a datatype

Поиск
Список
Период
Сортировка
От Oliver Fromme
Тема Re: can I define a hyperlink as a datatype
Дата
Msg-id 200409150919.i8F9JSHf052369@lurza.secnetix.de
обсуждение исходный текст
Ответ на Re: can I define a hyperlink as a datatype  (Josh Berkus <josh@agliodbs.com>)
Список 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

В списке pgsql-novice по дате отправления:

Предыдущее
От: Josh Berkus
Дата:
Сообщение: Re: can I define a hyperlink as a datatype
Следующее
От: Arthur van Dorp
Дата:
Сообщение: Re: can I define a hyperlink as a datatype