SQL spojovani tabulek ???
Karel Zak
zakkr na zf.jcu.cz
Pondělí Květen 13 11:27:11 CEST 2002
On Mon, May 13, 2002 at 11:11:52AM +0200, "Z?ka Ale?, Ing." wrote:
> > >
> > > > A nebo pouzit PostgreSQL a dedicnost tabulek kdy nad
> > celou hierarchii
> > > > takto vytvorenych tabulek jde pracovat jako s jednou tabulkou :-)
> > > > (pochopitelne to asi v SQL standardu nenajdete:-).
> > > >
> > >
> > > Kdyz uz se o tom mluvi, jde v tomto pripade nejak
> > udelat primary key
> > > nebo aspon unique index pres celou hierarchii?
> > > Proste mam tabulku A a v ni nejaky atribut ID jako
> > primary key, z ni
> > > zdedim tabulku B. A chci zajistit, aby se v B nemohl
> > objevit zaznam se
> > > stejnym ID, ktery uz existuje v A a naopak. Jde to nějak udelat?
> >
> > Docs:
> >
> > A limitation of the inheritance feature is that indexes (including
> > unique constraints) and foreign key constraints only apply to single
> > tables, not to their inheritance children. Thus, in the above
> > example, specifying that another table's column REFERENCES
> > cities(name) would allow the other table to contain city names but
> > not capital names. This deficiency will probably be fixed in some
> > future release.
> >
>
> Diky.
>
> Takze si to osetrit nejakym vlastnim zbesilym triggerem.
> Nebo je jestě nejaka jina cesta?
Mam aplikaci jejiz DB je postavena nad nekolika podobnyma tabulkama
svazanyma dedicnosti. Duvod byl oddelit pro urcite skupiny
zaznamu UPDATE/INSERT prava. Unikatnost se zajistuje celkem
jednoduchym triggerem (cca 100 radek v C) ktery tam dela SELECT
nad celou hierarchii.
Kazdopadne doporucuji si to dobre promyslet, nez takoouvou DB
udelate. Je to neprenositelne a pokud je mozne, aby nektere
veci ktere vas k tomu vedou resila aplikace (aplikacni server)
tak bych to asi nedelal.
Karel
--
Karel Zak <zakkr na zf.jcu.cz>
http://home.zf.jcu.cz/~zakkr/
C, PostgreSQL, PHP, WWW, http://docs.linux.cz, http://mape.jcu.cz
Další informace o konferenci Databases