in reply to Database setup for daily db
If you have not used DBI before then this article by MJD is a good place to start.
You would proceed along these lines. To begin create the database and connect to it. Now create the "TableIndex" table once only.
CREATE TABLE TableIndex ( table_date date, table_id integer )
Each day you add an entry to the "TableIndex" table that consists of the date and a unique name "table_id" for the days data table (the concatenated date would do or an MD5 hash or an incremented integer - whatever). Now create a new table called "table_id" and insert your days data. Each day you will add one record to the TableIndex table and create one new table in the database. This should get you started:
my ($dbh,$sth,$sql); # connect to database $dbh = DBI->connect('DBI:Oracle:mydata') or die "Couldn't connect to database: " . DBI->errstr; # do some stuff to get data into $date and $table_id # insert the days table date and table_id into the index $sql = 'INSERT INTO TableIndex VALUES (?,?)'; $sth = $dbh->prepare($sql) or die "Couldn't prepare SQL\n$sql\n" . $dbh->errstr; $sth->execute($date,$table_id) or die "Couldn't execute SQL\n$sql\n" . $dbh->errstr; $sth->finish; # create a new table to hold the days data $sql =<<SQL; CREATE TABLE "$table_id" ( data1 varchar(10), data2 varchar(10) ) SQL; # now execute this sql to create the table # insert the data into the new table $sql = qq/INSERT INTO "$table_id" VALUES (?,?)/; # now insert your data...etc
You can now access you data by date by quering the "TableIndex" table for the table id(s) you are interested in and then quering that/those table(s)
cheerstachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Database setup for daily db
by mce (Curate) on Oct 08, 2002 at 13:36 UTC | |
|
Re: Re: Database setup for daily db
by perleager (Pilgrim) on Oct 08, 2002 at 13:47 UTC | |
by zigdon (Deacon) on Oct 08, 2002 at 14:24 UTC | |
by perleager (Pilgrim) on Oct 08, 2002 at 22:57 UTC | |
by zigdon (Deacon) on Oct 09, 2002 at 00:30 UTC |