Adding header nam to any table

Started by Michael Vodepover 22 years ago3 messagesgeneral
Jump to latest
#1Michael Vodep
mvodep@gmx.net

Hi!
I am using postgresql with PHP and C. Is it possible to add header
information to every table? For example:
id | name | age
should be
User ID | Username | Age of user
This should be displayed, when i query the header information. Is this
possible? Maybe i can add a comment to every column header? Or is there a simple
way for storeing this additional information in a other table and solve this
problem by writting some special SQL statements?

Thanks!!
cu

--
COMPUTERBILD 15/03: Premium-e-mail-Dienste im Test
--------------------------------------------------
1. GMX TopMail - Platz 1 und Testsieger!
2. GMX ProMail - Platz 2 und Preis-Qualit�tssieger!
3. Arcor - 4. web.de - 5. T-Online - 6. freenet.de - 7. daybyday - 8. e-Post

#2Richard Huxton
dev@archonet.com
In reply to: Michael Vodep (#1)
Re: Adding header nam to any table

On Tuesday 09 September 2003 16:49, Michael Vodep wrote:

Hi!
I am using postgresql with PHP and C. Is it possible to add header
information to every table? For example:
id | name | age
should be
User ID | Username | Age of user
This should be displayed, when i query the header information. Is this
possible? Maybe i can add a comment to every column header? Or is there a
simple way for storeing this additional information in a other table and
solve this problem by writting some special SQL statements?

Well, one solution which I tend to use is to keep this information in my
application layer (PHP/C in your case).

Since PHP will need to know something about the structure of the database
anyway, I keep all this together. Something like:

$Tables['user_age'] = array(
'id' => array('type' => 'int', 'desc'=>'User ID'),
'name' => array( 'type'=>'text', 'desc'=>'User name' ),
'age' => array('type'=>'int', 'desc'=>'Age of user' )
);

In fact, where possible I like to generate the above table and my SQL from the
same definitions-file.

--
Richard Huxton
Archonet Ltd

#3Ron Johnson
ron.l.johnson@cox.net
In reply to: Michael Vodep (#1)
Re: Adding header nam to any table

On Tue, 2003-09-09 at 10:49, Michael Vodep wrote:

Hi!
I am using postgresql with PHP and C. Is it possible to add header
information to every table? For example:
id | name | age
should be
User ID | Username | Age of user

In psql, you can do:
SELECT id as "User ID", name as "Username", age as "Age of user"
FROM foobar;

A special table where you manually map field names to descriptive
would also work, and be generic.

--
-----------------------------------------------------------------
Ron Johnson, Jr. ron.l.johnson@cox.net
Jefferson, LA USA

"Fair is where you take your cows to be judged."
Unknown