[sqlite] INTERSECT optimization, is it possible?

2010-01-10 Thread Max Vlasov
Documentation says that INTERSECT implemented with temporary tables either
in memory or on disk. Is it always the case? The problem is that if I have
several selects (six for example) when each produces thousands of results
and the intersection is only hundreds the query takes about minute to
execute. But all these selects are properly ordered to do intersection
without extra files usage. For example I know that I can make it in my code
by splitting these selects into separated prepared statements and making
synchronous stepping outputting only if all steps have equal value(s). If
there's no such optimization, is it possible to implement it in the sqlite
engine? I know that having very complex query with many selects it would be
a hard task to recognize such a specific case but maybe it is easier than it
seems.

Thanks,

Max
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Reasons for SQLITE_CANTOPEN

2010-01-10 Thread Filip Navara
Hi!

Does "pragma journal_mode=truncate;" make any difference?
Is this on Windows?
Do you have TortoiseSVN installed on the same system?

If you answer Yes to all these questions then use Google, I have already
explained at least twice why it happens.

Best regards,
Filip Navara

On Sun, Jan 10, 2010 at 4:59 AM, Nikolaus Rath  wrote:

> Hello,
>
> I am accessing the same database from several threads, each using a
> separate connection. Shared cache is not enabled.
>
> When my program has been running for a while, I suddenly get an
> SQLITE_CANTOPEN error when I'm trying to open a database connection with
> a new thread. The database file, however, is definitively present and
> accessible.
>
> At the time of the error, there are probably around 30 threads holding
> database connections, and with certainty less than 213.
>
> (213 is the total number of threads that the program has created at that
> point, but most of them should have had only a short lifetime, so the
> actual number of active connections should be much smaller. I did not
> investigate the number of active threads closer, because even 213 active
> connection doesn't seem like a critical number to me).
>
> Can someone tell me under which conditions sqlite returns
> SQLITE_CANTOPEN, and how I can figure out what problem it encounters
> exactly?
>
>
> Best,
>
>
>   -Nikolaus
>
> --
>  »Time flies like an arrow, fruit flies like a Banana.«
>
>  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C
>
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Help with Transaction Error.

2010-01-10 Thread Simon Slavin

On 10 Jan 2010, at 4:56am, Vathir wrote:

> I am trying to use SQL Jet within my java application, but I consistently get
> the following error when I run this section of code.  For some reason I
> cannot open this particular database.

If you open the database using the command-line tool, do you get the same error 
?  If not, can you read the contents ?

Simon.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Import a other database. Search for the fastes way

2010-01-10 Thread Carsten Giesen
Hello,

Thanks. That's rock 
Greate.

Cu

Carsten


-Ursprüngliche Nachricht-
Von: sqlite-users-boun...@sqlite.org
[mailto:sqlite-users-boun...@sqlite.org] Im Auftrag von Dan Bishop
Gesendet: Samstag, 9. Januar 2010 18:14
An: General Discussion of SQLite Database
Betreff: Re: [sqlite] Import a other database. Search for the fastes way

Carsten Giesen wrote:
> Now my question.
>
> I work on a way to have a cache DB from the Main Server on the PC of my
> client.
> In the case the server is down they can go on working. (Like Outlook and
> Exchange)
>
>  
>
> For the first time I have to copy a lot of data from the main server.
>
> In the moment I do it Table by Table, and Row by Row in a for each loop.
>
> An then "INSERT INTO {table} (Field..) values (Item.)"
>
>  
> Is the a faster way?
>   
Put a "BEGIN TRANSACTION" before your loop and a "COMMIT TRANSACTION" 
after it.  Otherwise, each INSERT statement is its own transaction, 
which is *much* slower.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Import a other database. Search for the fastes way

2010-01-10 Thread Wolfgang Enzinger
Am Sat, 9 Jan 2010 22:00:04 +0100 schrieb Carsten Giesen:

[Transactions]

> Thanks. That's rock 
> Greate.

Next, play with some PRAGMA settings to achieve even more speed,
especially:

PRAGMA cache_size = Number-of-pages;
PRAGMA page_size = bytes;

Also (it's not clear whether you do this already) use prepared statements
(sqlite3_prepare*) with parameters (sqlite3_bind_*) instead of building a
new SQL string for each row to be inserted.

HTH,
Wolfgang

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Reasons for SQLITE_CANTOPEN

2010-01-10 Thread Nikolaus Rath
Filip Navara  writes:
>> I am accessing the same database from several threads, each using a
>> separate connection. Shared cache is not enabled.
>>
>> When my program has been running for a while, I suddenly get an
>> SQLITE_CANTOPEN error when I'm trying to open a database connection with
>> a new thread. The database file, however, is definitively present and
>> accessible.
> Hi!
>
> Does "pragma journal_mode=truncate;" make any difference?
> Is this on Windows?
> Do you have TortoiseSVN installed on the same system?

No to all questions, I'm afraid. Seems that my problem is a different one.


   -Nikolaus

-- 
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Reasons for SQLITE_CANTOPEN

2010-01-10 Thread Edzard Pasma

Op 10-jan-2010, om 19:25 heeft Nikolaus Rath het volgende geschreven:

> Filip Navara  writes:
>>> I am accessing the same database from several threads, each using a
>>> separate connection. Shared cache is not enabled.
>>>
>>> When my program has been running for a while, I suddenly get an
>>> SQLITE_CANTOPEN error when I'm trying to open a database  
>>> connection with
>>> a new thread. The database file, however, is definitively present  
>>> and
>>> accessible.
>> Hi!
>>
>> Does "pragma journal_mode=truncate;" make any difference?
>> Is this on Windows?
>> Do you have TortoiseSVN installed on the same system?
>
> No to all questions, I'm afraid. Seems that my problem is a  
> different one.
>
>
>-Nikolaus

Does your application attach at least 20 further databases within  
each of the 15 connections?
Does it open at least 250 files any other way?

If any yes, then you have too many open files!

Regards, Edzard Pasma


___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Reasons for SQLITE_CANTOPEN

2010-01-10 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Nikolaus Rath wrote:
> Can someone tell me under which conditions sqlite returns
> SQLITE_CANTOPEN, and how I can figure out what problem it encounters
> exactly?

Start your program prefixed by 'strace -f -o /tmp/strace.log -s 200' and
then look for the database filename after the problem has occurred in
/tmp/strace.log.  You should see some sort of failing system call.

Roger
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAktKJawACgkQmOOfHg372QQAwwCg0ZIqD7c8qDZvM8930GuhSerc
EV8AoLEQY5xUrpzUqqkand0rncIHM23X
=tUzt
-END PGP SIGNATURE-
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] INTERSECT optimization, is it possible?

2010-01-10 Thread darren
Considering that INTERSECT is logically nothing but a special case of
relational join (the exact opposite of cartesian product), where all
columns are involved in the join condition, you should just be able to
reuse any optimizations that exist for join, including primary/unique
keys/etc. -- Darren Duncan

> Documentation says that INTERSECT implemented with temporary tables either
> in memory or on disk. Is it always the case? The problem is that if I have
> several selects (six for example) when each produces thousands of results
> and the intersection is only hundreds the query takes about minute to
> execute. But all these selects are properly ordered to do intersection
> without extra files usage. For example I know that I can make it in my
> code
> by splitting these selects into separated prepared statements and making
> synchronous stepping outputting only if all steps have equal value(s). If
> there's no such optimization, is it possible to implement it in the sqlite
> engine? I know that having very complex query with many selects it would
> be
> a hard task to recognize such a specific case but maybe it is easier than
> it
> seems.


___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] INTERSECT optimization, is it possible?

2010-01-10 Thread D. Richard Hipp

On Jan 10, 2010, at 4:50 AM, Max Vlasov wrote:

> Documentation says that INTERSECT implemented with temporary tables  
> either
> in memory or on disk. Is it always the case?

No.

If there is an ORDER BY clause, SQLite may run each subquery as a  
separate co-routine and merge the results.  If the ORDER BY on both  
subqueries can be computed using indices, then the INTERSECT will run  
in either linear or logarithmic time (depending on what indices are  
available) and in constant space.  This is also true of UNION and  
EXCEPT.

If there is an ORDER BY clause but there does not exist indices needed  
to implement the ORDER BY for one or both subqueries, then the  
subquery might get evaluated into a temporary table, and sorted there,  
prior to the merge step.

I *think* it will always be the case that if an INTERSECT query has an  
ORDER BY clause and if sqlite3_stmt_status(db, SQLITE_STMTSTATUS_SORT,  
1) returns 0, then the query does not use temporary tables and runs in  
constant space.  But I might be wrong.  And in any event, that rule is  
subject to change in a future release if we decide we can get better  
performance by doing things differently.

D. Richard Hipp
d...@hwaci.com



___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] INTERSECT optimization, is it possible?

2010-01-10 Thread Max Vlasov
On Mon, Jan 11, 2010 at 12:56 AM, D. Richard Hipp  wrote:

>
> On Jan 10, 2010, at 4:50 AM, Max Vlasov wrote:
>
> > Documentation says that INTERSECT implemented with temporary tables
> > either
> > in memory or on disk. Is it always the case?
>
> No.
>
> If there is an ORDER BY clause, SQLite may run each subquery as a
> separate co-routine and merge the results.


Thanks a lot,
At the first place I tried to append ORDER BY in every query that led to
"ORDER BY clause should come after intersect not before" error, but I did
not read this message properly just to place the ORDER BY once at the end of
the query. The time improved dramatically from 50 seconds to 6 and it was an
extreme case so the real life queries dropped to below a second.
Needless to say, but I'm very impressed about how sqlite takes almost every
aspect into account
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Reasons for SQLITE_CANTOPEN

2010-01-10 Thread Nikolaus Rath
Edzard Pasma  writes:
> Op 10-jan-2010, om 19:25 heeft Nikolaus Rath het volgende geschreven:
>
>> Filip Navara  writes:
 I am accessing the same database from several threads, each using a
 separate connection. Shared cache is not enabled.

 When my program has been running for a while, I suddenly get an
 SQLITE_CANTOPEN error when I'm trying to open a database  
 connection with
 a new thread. The database file, however, is definitively present  
 and
 accessible.
>>> Hi!
>>>
>>> Does "pragma journal_mode=truncate;" make any difference?
>>> Is this on Windows?
>>> Do you have TortoiseSVN installed on the same system?
>>
>> No to all questions, I'm afraid. Seems that my problem is a  
>> different one.
>
> Does your application attach at least 20 further databases within  
> each of the 15 connections?
> Does it open at least 250 files any other way?
>
> If any yes, then you have too many open files!

No, there is only one database for each connection. The idea with the
open files may still be a good one though, I will look into that. But
why should the limit be 250? On this system I have an ulimit of 1024
open fds, and I guess that on other systems it would at least still be
some power of 2.

Best,

   -Nikolaus

-- 
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] graphs and sql

2010-01-10 Thread Dan Bishop
Robert Citek wrote:
> Hello all,
>
> Does anyone have any recommendations for books or other resources that
> deal with working with graphs (i.e. vertexes and edges) using sql?
>
> For example, if I could store a graph in a sqlite database, I'd like
> to query the database to know if the graph contains a Eulerian
> path[1].
>
> [1] http://en.wikipedia.org/wiki/Eulerian_path
I don't think that SQL is the best language for working with graphs, but:

CREATE TABLE Graph (
NodeFrom INTEGER,
NodeTo INTEGER
);

-- Seven Bridges of Königsberg
BEGIN;
INSERT INTO Graph VALUES (1, 2);
INSERT INTO Graph VALUES (1, 2);
INSERT INTO Graph VALUES (1, 3);
INSERT INTO Graph VALUES (2, 3);
INSERT INTO Graph VALUES (2, 4);
INSERT INTO Graph VALUES (2, 4);
INSERT INTO Graph VALUES (3, 4);
COMMIT;

CREATE TABLE Degrees AS
SELECT NodeFrom AS Node, COUNT(*) AS Degree FROM
(SELECT NodeFrom, NodeTo From Graph UNION ALL
SELECT NodeTo, NodeFrom FROM Graph)
GROUP BY NodeFrom;

-- Find the number of odd nodes
-- If 0, there is an Eulerian circuit/tour
-- If 0 or 2, there is an Eulerian path/walk
SELECT SUM(Degree & 1) FROM Degrees;

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Performace regression bug of sqlite 3.6.18

2010-01-10 Thread Hub Dog
I think I found a performance regression bug of sqlite 3.6.1 8. A sql will
cost 1800 seconds to return the query result with sqlite 3.6.18 and with the
previous version it only cost about 170 seconds.

I just attach the sql can reproduce the bug under below. But the database is
a little large (4M), how to upload it to the mail list?

-- romermb's incredible combination of events, shared events plus 'marriage'
and alternate names as Facts 2010-01-06
-- revised by ve3meo to to bring out RoleName from RoleTableand Sharee's
Names from NameTable, tried to speed up using UNION ALL - not much gain -
still ~270 secs on a 50,000 event, 16,000 person table.
-- revised by romermb on 2010-01-07 to incorporate COUNT, GROUP BY

-- start with a table of nominally female spouses for the nominally male
partners (RIN in FatherID) as a 'fact' for the latter - a Family, even if no
actual Marriage
SELECT FactTypeTable.Name COLLATE NOCASE AS Fact, 'Principal' AS 'Role
Type', NameTable1.OwnerID AS RIN, NameTable1.Surname COLLATE NOCASE AS
Surname, NameTable1.Suffix COLLATE NOCASE AS Suffix, NameTable1.Prefix
COLLATE NOCASE AS Prefix, NameTable1.Given COLLATE NOCASE AS 'Given Name',
NameTable2.OwnerID AS 'Sharer RIN', NameTable2.Surname COLLATE NOCASE AS
'Sharer Surname', NameTable2.Suffix COLLATE NOCASE AS 'Sharer Suffix',
NameTable2.Prefix COLLATE NOCASE AS 'Sharer Prefix', NameTable2.Given
COLLATE NOCASE AS 'Sharer Given Name', COUNT(1) AS Count
FROM EventTable
INNER JOIN FactTypeTable ON EventTable.EventType = FactTypeTable.FactTypeID
INNER JOIN FamilyTable ON EventTable.OwnerID = FamilyTable.FamilyID
INNER JOIN NameTable AS NameTable1 ON FamilyTable.FatherID =
NameTable1.OwnerID
INNER JOIN NameTable AS NameTable2 ON FamilyTable.MotherID =
NameTable2.OwnerID
WHERE EventTable.OwnerType = 1 AND NameTable1.IsPrimary = 1 AND
NameTable2.IsPrimary = 1
GROUP BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12

UNION ALL
-- add nominally male spouses of nominally female partners (RIN in MotherID)
as a 'fact' for the latter - a family even if no actual Marriage
SELECT FactTypeTable.Name COLLATE NOCASE, 'Principal', NameTable2.OwnerID,
NameTable2.Surname COLLATE NOCASE, NameTable2.Suffix COLLATE NOCASE,
NameTable2.Prefix COLLATE NOCASE, NameTable2.Given COLLATE NOCASE,
NameTable1.OwnerID, NameTable1.Surname COLLATE NOCASE, NameTable1.Suffix
COLLATE NOCASE, NameTable1.Prefix COLLATE NOCASE, NameTable1.Given COLLATE
NOCASE, COUNT(1)
FROM EventTable
INNER JOIN FactTypeTable ON EventTable.EventType = FactTypeTable.FactTypeID
INNER JOIN FamilyTable ON EventTable.OwnerID = FamilyTable.FamilyID
INNER JOIN NameTable AS NameTable1 ON FamilyTable.FatherID =
NameTable1.OwnerID
INNER JOIN NameTable AS NameTable2 ON FamilyTable.MotherID =
NameTable2.OwnerID
WHERE EventTable.OwnerType = 1 AND NameTable1.IsPrimary = 1 AND
NameTable2.IsPrimary = 1
GROUP BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12

UNION ALL
-- add all events for Individual
SELECT FactTypeTable.Name COLLATE NOCASE, 'Principal', NameTable.OwnerID,
NameTable.Surname COLLATE NOCASE, NameTable.Suffix COLLATE NOCASE,
NameTable.Prefix COLLATE NOCASE, NameTable.Given COLLATE NOCASE, NULL, NULL,
NULL, NULL, NULL, COUNT(1)
FROM EventTable
INNER JOIN FactTypeTable ON EventTable.EventType = FactTypeTable.FactTypeID
INNER JOIN NameTable ON EventTable.OwnerID = NameTable.OwnerID
WHERE EventTable.OwnerType = 0 AND NameTable.IsPrimary = 1
GROUP BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12

UNION ALL
-- add Alternate Name as a 'Fact'
SELECT 'Alternate name', 'Principal', OwnerID, Surname COLLATE NOCASE,
Suffix COLLATE NOCASE, Prefix COLLATE NOCASE, Given COLLATE NOCASE, NULL,
NULL, NULL, NULL, NULL, COUNT(1)
FROM NameTable
WHERE IsPrimary = 0
GROUP BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12

UNION ALL
-- add shared events other than family as 'Facts' - revised by ve3meo to
bring out RoleName from RoleTableand Sharee's Names from NameTable
SELECT FactTypeTable.Name COLLATE NOCASE, RoleName COLLATE NOCASE,
NameTable1.OwnerID, NameTable1.Surname COLLATE NOCASE, NameTable1.Suffix
COLLATE NOCASE, NameTable1.Prefix COLLATE NOCASE, NameTable1.Given COLLATE
NOCASE, EventTable.OwnerID, NameTable2.Surname COLLATE NOCASE,
NameTable2.Suffix COLLATE NOCASE, NameTable2.Prefix COLLATE NOCASE,
NameTable2.Given COLLATE NOCASE, COUNT(1)
FROM WitnessTable
INNER JOIN roletable ON Role = RoleID
INNER JOIN EventTable ON WitnessTable.EventID = EventTable.EventID
INNER JOIN NameTable AS NameTable1 ON WitnessTable.PersonID =
NameTable1.OwnerID
INNER JOIN NameTable AS NameTable2 ON EventTable.OwnerID =
NameTable2.OwnerID
INNER JOIN FactTypeTable ON EventTable.EventType = FactTypeTable.FactTypeID
WHERE NameTable1.IsPrimary = 1
GROUP BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12

ORDER BY RIN;

best regards
chinshou
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] graphs and sql

2010-01-10 Thread Robert Citek
On Sat, Jan 9, 2010 at 5:44 PM, Jay A. Kreibich  wrote:
> On Sat, Jan 09, 2010 at 03:41:24PM -0500, Robert Citek scratched on the wall:
>> Does anyone have any recommendations for books or other resources that
>> deal with working with graphs (i.e. vertexes and edges) using sql?
>
>  Joe Celko's "Trees and Hierarchies in SQL for Smarties" has a bit of
>  information, but the primary focus is trees and DAGs.
>
>  His more general "SQL For Smarties, Advanced SQL Programming" has a
>  number of pages on the topic as well.  That book is extremely useful
>  for any number of other topics as well.

Thanks.  I'll have a look at both of those for a start.

Regards,
- Robert
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] graphs and sql

2010-01-10 Thread Robert Citek
On Sun, Jan 10, 2010 at 8:06 PM, Dan Bishop  wrote:
> Robert Citek wrote:
>> Does anyone have any recommendations for books or other resources that
>> deal with working with graphs (i.e. vertexes and edges) using sql?
>>
> I don't think that SQL is the best language for working with graphs, but:
>
> CREATE TABLE Graph (
> NodeFrom INTEGER,
> NodeTo INTEGER
> );

Yes, the Koenigsberg bridge problem is just one example of what I am
referring to.

I was working on creating a more general model initially with just two
tables: one for vertexes and one for edges, which is a pairing of
vertexes.  For example:

create table vertexes ( vertex integer ) ;
create table edges ( v1 integer, v2 integer ) ;
BEGIN;
INSERT INTO vertexes VALUES (1);
INSERT INTO vertexes VALUES (2);
INSERT INTO vertexes VALUES (3);
INSERT INTO vertexes VALUES (4);
COMMIT;

To create a complete graph:

INSERT INTO edges
SELECT v1.vertex, v2.vertex
FROM vertexes v1 JOIN vertexes v2
WHERE v2.vertex > v1.vertex

To generate the irreflexive symmetric relation on vertexes:

CREATE VIEW isr AS
SELECT v1.vertex, v2.vertex
FROM vertexes v1 JOIN vertexes v2
WHERE v2.vertex != v1.vertex

So, there seem to be ways of working with graphs within sql.  I was
just curious to know if there were texts that cover this subject.  Joe
Celko's books seem like one source.  Are there others?

As for SQL not being the best for working with graphs, I'm ok with
that as I can use sqlite3 for storing and retrieving the graph data as
well as some of the more simpler manipulations, and then use some
other language for more sophisticated manipulations.

Regards,
- Robert
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] graphs and sql

2010-01-10 Thread Nick Atty
Robert Citek wrote:
> On Sun, Jan 10, 2010 at 8:06 PM, Dan Bishop  wrote:
>> Robert Citek wrote:
>>> Does anyone have any recommendations for books or other resources that
>>> deal with working with graphs (i.e. vertexes and edges) using sql?
>>>
>> I don't think that SQL is the best language for working with graphs, but:
>>
>> CREATE TABLE Graph (
>> NodeFrom INTEGER,
>> NodeTo INTEGER
>> );
> 
> Yes, the Koenigsberg bridge problem is just one example of what I am
> referring to.
> 
> I was working on creating a more general model initially with just two
> tables: one for vertexes and one for edges, which is a pairing of
> vertexes.  For example:
> 
> create table vertexes ( vertex integer ) ;
> create table edges ( v1 integer, v2 integer ) ;
> BEGIN;
> INSERT INTO vertexes VALUES (1);
> INSERT INTO vertexes VALUES (2);
> INSERT INTO vertexes VALUES (3);
> INSERT INTO vertexes VALUES (4);
> COMMIT;

I store all the data for my waterways route planner in SQLite, but I 
load it into memory for running Dijkstra's algorithm on it to find the 
shortest (when weighted) paths.   It's at canalplan.eu if anyone wants a 
play.

One problem you rapidly run into when storing graphs in SQL, in my 
limited and non-expert experience, is that - as in this example - you 
end up with edge records each of which refers to two vertices.  My 
database maintenance and update code is riddled with:

SELECT ... FROM link WHERE place1=x AND place2=y OR place1=y AND place2=x;

and similar.  Apart from imposing a condition (such as always having v1 
< v2 in the example code) is there any sensible way round this?
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Minor bug: v3.6.22 not showing up as release in fossil!

2010-01-10 Thread WClark
Hi, not a major one, but...

version 3.6.22 has not been tagged as "release" in the fossil repository 
(e.g. in http://www.sqlite.org/src/timeline?t=release).

Cheers
Will
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users