optimize table structure, idea from Martynas Venckus

This commit is contained in:
espie 2006-11-03 23:26:41 +00:00
parent 19abee34c6
commit 6837ca4337
2 changed files with 8 additions and 6 deletions

View File

@ -1,7 +1,7 @@
# $OpenBSD: Makefile,v 1.6 2006/11/03 23:03:09 espie Exp $
# $OpenBSD: Makefile,v 1.7 2006/11/03 23:26:41 espie Exp $
CATEGORIES= databases
DISTNAME= sqlports-0.4
DISTNAME= sqlports-0.5
DISTFILES=
COMMENT= 'sqlite database of ports'
MAINTAINER= Marc Espie <espie@openbsd.org>

View File

@ -1,5 +1,5 @@
#! /usr/bin/perl
# $OpenBSD: mksqlitedb,v 1.2 2006/11/03 23:03:09 espie Exp $
# $OpenBSD: mksqlitedb,v 1.3 2006/11/03 23:26:41 espie Exp $
#
# Copyright (c) 2006 Marc Espie <espie@openbsd.org>
#
@ -304,7 +304,7 @@ my $vars = {
# create the various tables, dropping old versions
for my $t (qw(Categories Flavors Multi Modules Configure ConfigureArgs Wantlib Descr)) {
for my $t (qw(Categories Flavors Multi Modules Configure ConfigureArgs Wantlib)) {
$db->do("DROP TABLE IF EXISTS $t");
$db->do("CREATE TABLE $t (FULLPKGPATH TEXT NOT NULL, VALUE TEXT NOT NULL, UNIQUE(FULLPKGPATH, VALUE))");
}
@ -313,10 +313,12 @@ $db->do("CREATE TABLE Depends (FULLPKGPATH TEXT NOT NULL, FULLDEPENDS TEXT NOT N
$db->do("DROP TABLE IF EXISTS Shared_Libs");
$db->do("CREATE TABLE Shared_Libs (FULLPKGPATH TEXT NOT NULL, LIBNAME TEXT NOT NULL, VERSION TEXT NOT NULL, UNIQUE (FULLPKGPATH, LIBNAME))");
$db->do("DROP TABLE IF EXISTS Ports");
$db->do("CREATE TABLE Ports (FULLPKGPATH TEXT PRIMARY KEY, ".
$db->do("CREATE TABLE Ports (FULLPKGPATH TEXT NOT NULL PRIMARY KEY, ".
join(',', (map {$_." TEXT"} (keys %$vars))).")");
$db->do("DROP TABLE IF EXISTS Paths");
$db->do("CREATE TABLE Paths (FULLPKGPATH TEXT PRIMARY KEY, PKGPATH TEXT NOT NULL)");
$db->do("CREATE TABLE Paths (FULLPKGPATH TEXT NOT NULL PRIMARY KEY, PKGPATH TEXT NOT NULL)");
$db->do("DROP TABLE IF EXISTS Descr");
$db->do("CREATE TABLE Descr (FULLPKGPATH TEXT NOT NULL PRIMARY KEY, VALUE TEXT NOT NULL)");
$db->commit();
my $stmt = $db->prepare("SELECT RowID FROM Ports WHERE FULLPKGPATH=(?)");