Re: SQL Statement Help Needed

Поиск
Список
Период
Сортировка
От
Тема Re: SQL Statement Help Needed
Дата
Msg-id 20051206002022.37586.qmail@web33308.mail.mud.yahoo.com
обсуждение исходный текст
Ответ на Re: SQL Statement Help Needed  (Frank Bax <fbax@sympatico.ca>)
Список pgsql-novice
to the OP (i couldn't find it, so i'm replying to this
note),

have you thought about normalizing your data structure
a bit further?

your table structure currently appears to be:

table_employees
employee_id
employee_name
home_phone
work_phone
cell_phone
pager
fax
etc...

you could set it up as follows...

table_employees
employee_id
employee_name

table_phone_number
phone_number_id
phone_number
type_id

table_type_phone_number (note: type_name is where
"home", "work", "fax", etc. gets entered)
type_id
type_name

table_link_employee_phone_number
employee_id
phone_number_id

the reason for doing this is that you eliminate
database dead space (people that don't have faxes
won't store a null in the db (i think it is null) and
the db won't have to manage the null values).

best of luck.



--- Frank Bax <fbax@sympatico.ca> wrote:

> At 04:12 AM 12/4/05, Michael Avila wrote:
> >I have a table with members named members. Each
> member has only 1 record.
> >A member can have more than one telephone number
> (home,
> >work, cell, pager, fax, etc.). I want to print out
> the telephone numbers of
> >the members. Is it possible to do it in one SQL
> statement like with a JOIN
>
> Yes.
>
> >do I need to get the members and then loop through
> the
> >membertelephones to get the telephone numbers?
>
> No.
>
> >Is it possible to do a JOIN
> >with a table with one record with a table with
> multiple records?
>
> Yes.
>
>
> >SELECT * FROM member
> >
> >SELECT * FROM membertelephone WHERE member_id = the
> id from the above SELECT
>
>          http://en.wikipedia.org/wiki/Join_%28SQL%29
>
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please
> send an appropriate
>        subscribe-nomail command to
> majordomo@postgresql.org so that your
>        message can get through to the mailing list
> cleanly
>




__________________________________________
Yahoo! DSL – Something to write home about.
Just $16.99/mo. or less.
dsl.yahoo.com


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

Предыдущее
От: Mike Ellsworth
Дата:
Сообщение: OT - Development question
Следующее
От:
Дата:
Сообщение: Re: fk problems with 0..n relations