home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.databases:7873 comp.databases.theory:613
- Newsgroups: comp.databases,comp.databases.theory
- Path: sparky!uunet!mcsun!chsun!bernina!neptune!nugget.inf.ethz.ch!marti
- From: marti@nugget.inf.ethz.ch (Robert Marti)
- Subject: Re: Simple SQL Join question
- Message-ID: <1992Nov16.091930.14764@neptune.inf.ethz.ch>
- Sender: news@neptune.inf.ethz.ch (Mr News)
- Nntp-Posting-Host: nugget.inf.ethz.ch
- Organization: Dept. Informatik, Swiss Federal Institute of Technology (ETH), Zurich, CH
- References: <1992Nov13.152835.1@ilp.mit.edu>
- Date: Mon, 16 Nov 1992 09:19:30 GMT
- Lines: 43
-
- In article <1992Nov13.152835.1@ilp.mit.edu>, gold@ilp.mit.edu writes:
- |> I have a basic SQL question regarding joins. [...] A typical
- |> query would ask for:
- |> "List employee names and ids and each employee's
- |> department(s), publication(s), project(s),
- |> expertise keyword(s)
- |> Some employees have 10+ expertise keywords, 2-3 departments, 1-30
- |> projects, 1-500 publications.
- |>
- |> The SELECT statement that I am using is listed below. [...]
- |> Is there a simplier, or less resource-consuming way of using SQL to
- |> answer the user's question (in quotes above) rather than using the
- |> SELECT statement below. Thank you for any assistance!
- |>
- |> SELECT [...]
- |> FROM employee, employee_dept, dept, employee_project, project,
- |> employee_publication, publication, employee_expertise, expertise
- |> WHERE [ ... lots of join conditions deleted ...]
-
- As David Masterson points out in his posting, you have practically
- no other choice than to issue separate queries (typically 3-way joins
- joining employee, employee_something, and something) and to "join"
- their results "manually", by writing a C-ESQL program, or by using
- some sort of 4GL (whatever that means) which supports the stuff you
- want.
-
- Also, be aware that your SELECT-statement above will not return
- _any_ information on employees who have no corresponding information
- in _one_ of the tables joined with employee. In this case, you'd
- have to use outer joins, a feature which was not in the 89 SQL
- standard. (However, as far as I know, outer joins are supported
- by many systems. Also, for what it's worth, I think outer joins
- made it into the 92 SQL standard.)
-
- Your example is IMHO one of the biggest weaknesses of relational
- systems (or 1NF, if you will) as opposed to, for example, object-
- oriented systems.
-
- --
- Robert Marti | Phone: +41 1 254 72 60
- Informationssysteme | FAX: +41 1 262 39 73
- ETH-Zentrum | E-Mail: marti@inf.ethz.ch
- CH-8092 Zurich, Switzerland |
-