help-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-glpk] Database connectivity in MathProg


From: glpk xypron
Subject: Re: [Help-glpk] Database connectivity in MathProg
Date: Mon, 11 Feb 2008 20:45:01 +0100

Hello Andrew!

> > In a SQL table with key columns for any key combination of keys there
> can
> > be only one record in the table.
> 
> AFAIK, this is not necessary.

I should have written primary keys. See 
http://dev.mysql.com/doc/refman/5.0/en/constraint-primary-key.html
http://en.wikipedia.org/wiki/Primary_key

> 
> Since tables are not deleted, information about key columns will be
> kept. Let, for example, there is a table created as:
> 
> CREATE TABLE FOO
> (  I INT,
>    J CHAR(8),
>    P INT,
>    Q CHAR(20),
>    PRIMARY KEY(I, J)
> );
> 
> Then the output table in MathProg might look like:
> 
> table mytab{i in S1, j in S2: i != j} OUT "..." "FOO":
>    i+1 ~ I, j ~ J, a[i,j+1]+123 ~ P, b[i-1,j] ~ Q;
> 
> which assumes deleting all existing records from table FOO and then
> inserting new records:
> 
> INSERT INTO FOO(I, J, P, Q) VALUES(...)

I understand that the content information for the key column can be conveyed in 
Your syntax too, but not the meta information which column is key.

Will it be wise to delete all existing records?

Another solution would be to UPDATE records with preexisting keys and INSERTing 
the rest.

This would allow the results of multiple runs of GPLK to be collected.

Especially when connecting to data sources like csv files, or spreadsheets 
which do not contain meta information identifying keys it is necessary that 
MathProg defines which columns are the keys if UPDATE and INSERT are to be used.

This is why AMPL is identifying key columns with brackets [] in the table out 
statement.

Implementing a syntax
table t OUT ... : {...}->[k ~ K, ...], ...;
will not cause significantly more effort for the programmer then
table t {...} OUT ... : k ~ K, ...;
but will convey the necessary information to uniquely identify the key columns 
for the data base interface.
If this looks more appealing to You, You might use:
table t {...} OUT ... : [k ~ K, ...], ...;

Best regards

Xypron
-- 
Psssst! Schon vom neuen GMX MultiMessenger gehört?
Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger




reply via email to

[Prev in Thread] Current Thread [Next in Thread]