[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: gEDA-user: Database on symbols, footprints and other (was "Re: gattrib")



On Apr 29, 2010, at 1:01 PM, Armin Faltl wrote:

> Another strange thing with gparts:
> 
> in 'sql/mysql/create-basic.sql' one finds:
> ------------------------ cut ----------------------------
> ...
> CREATE TABLE Symbol (
> 
>   SymbolID    INTEGER UNSIGNED  NOT NULL AUTO_INCREMENT,
>   SymbolPath  VARCHAR(500)      NOT NULL,
>   DeviceID    INTEGER UNSIGNED  NOT NULL,
> 
>   PRIMARY KEY ( SymbolID ),
>   FOREIGN KEY ( DeviceID ) REFERENCES Device,
>   UNIQUE ( SymbolPath )
>   );
> 
> 
> -- Create a table for symbol details (comments).
> --
> -- Each symbol may have many comments.
> --
> CREATE TABLE SymbolDetail (
> 
>   SymbolID  INTEGER UNSIGNED  NOT NULL AUTO_INCREMENT,
>   Detail    VARCHAR(500)      NOT NULL,
> 
>   FOREIGN KEY ( SymbolID ) REFERENCES Symbol,
>   UNIQUE ( SymbolID, Detail )
>   );
> ...
> ------------------------ cut -----------------------------
> 
> what is the purpose of auto-increment on a foreign key?
> Auto-increment would probably be the default behavior, but as it
> will break the foreign key constraint this, same as not assigning
> anything will prevent creation of that row. Actually it is worse
> (at least with PostgreSQL): the autoincrement counter falls
> behind, if the default behavior is not used.
> It can be assumed, that the SymbolID's from "Symbol" will form a gapless sequence.
> If for some reason, the SymbolID gets missed during creation of a
> SymbolDetail, the AUTO_INCREMENT will produce an integer
> that is probably low, because this is a bug. And this will happily
> attach the detail to a random symbol, instead of raising an exception.
> 
> Wrong?
> 
> Armin

The AUTO_INCREMENT should not be there, but no problem occurs because of it.
I'll remove it in a subsequent patch.

Cheers,
Ed


_______________________________________________
geda-user mailing list
geda-user@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user