From: Rob Kinyon Date: Sat, 5 Dec 2009 20:46:18 +0000 (-0500) Subject: Moved a few things and started on the MySQL schema X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits%2FDBM-Deep.git;a=commitdiff_plain;h=18bc2fa6f00cd17c961f2a7fe94296fefbf569c4 Moved a few things and started on the MySQL schema --- diff --git a/etc/mysql_tables.sql b/etc/mysql_tables.sql index f054e5d..7a30a53 100644 --- a/etc/mysql_tables.sql +++ b/etc/mysql_tables.sql @@ -1,57 +1,74 @@ -DROP TABLE IF EXISTS `rec_array`; -CREATE TABLE `rec_array` ( - `id` bigint(20) unsigned NOT NULL, - PRIMARY KEY (`id`) +DROP TABLE IF EXISTS references; +CREATE TABLE references ( + id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY + ,`type` ENUM( 'hash', 'array' ) NOT NULL DEFAULT 'hash' + ,refcount BIGINT UNSIGNED NOT NULL DEFAULT 1 ); -DROP TABLE IF EXISTS `rec_array_item`; -CREATE TABLE `rec_array_item` ( - `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, - `array` bigint(20) NOT NULL, - `pos` bigint(20) NOT NULL, - `value_data` varchar(255) DEFAULT NULL, - `value_type` enum('array','data','hash','text','value') NOT NULL DEFAULT 'value', - PRIMARY KEY (`id`), - UNIQUE KEY `array_2` (`array`,`pos`) -); - -DROP TABLE IF EXISTS `rec_hash`; -CREATE TABLE `rec_hash` ( - `id` bigint(20) unsigned NOT NULL, - PRIMARY KEY (`id`) -); - -DROP TABLE IF EXISTS `rec_hash_item`; -CREATE TABLE `rec_hash_item` ( - `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, - `hash` bigint(20) NOT NULL, - `key_data` varchar(255) DEFAULT NULL, - `key_hash` varchar(22) NOT NULL, - `key_type` enum('text','value') NOT NULL DEFAULT 'value', - `value_data` varchar(255) DEFAULT NULL, - `value_type` enum('array','data','hash','text','value') NOT NULL DEFAULT 'value', - PRIMARY KEY (`id`), - UNIQUE KEY `hash_2` (`hash`,`key_hash`) -); - -DROP TABLE IF EXISTS `rec_item`; -CREATE TABLE `rec_item` ( - `id` bigint(20) NOT NULL AUTO_INCREMENT, - `item_type` enum('array','hash') NOT NULL DEFAULT 'hash', - PRIMARY KEY (`id`) -); - -DROP TABLE IF EXISTS `rec_value_data`; -CREATE TABLE `rec_value_data` ( - `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, - `data` longblob NOT NULL, - PRIMARY KEY (`id`) -); - -DROP TABLE IF EXISTS `rec_value_text`; -CREATE TABLE `rec_value_text` ( - `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, - `data` longtext NOT NULL, - PRIMARY KEY (`id`) +DROP TABLE IF EXISTS datas; +CREATE TABLE data ( + id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY + ,reference_id BIGINT UNSIGNED NOT NULL + ,key TEXT NOT NULL + ,value TEXT + ,class TEXT + ,FOREIGN KEY (reference_id) REFERENCES references (id) ); +--DROP TABLE IF EXISTS `rec_array`; +--CREATE TABLE `rec_array` ( +-- `id` bigint(20) unsigned NOT NULL, +-- PRIMARY KEY (`id`) +--); +-- +--DROP TABLE IF EXISTS `rec_array_item`; +--CREATE TABLE `rec_array_item` ( +-- `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, +-- `array` bigint(20) NOT NULL, +-- `pos` bigint(20) NOT NULL, +-- `value_data` varchar(255) DEFAULT NULL, +-- `value_type` enum('array','data','hash','text','value') NOT NULL DEFAULT 'value', +-- PRIMARY KEY (`id`), +-- UNIQUE KEY `array_2` (`array`,`pos`) +--); +-- +--DROP TABLE IF EXISTS `rec_hash`; +--CREATE TABLE `rec_hash` ( +-- `id` bigint(20) unsigned NOT NULL, +-- PRIMARY KEY (`id`) +--); +-- +--DROP TABLE IF EXISTS `rec_hash_item`; +--CREATE TABLE `rec_hash_item` ( +-- `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, +-- `hash` bigint(20) NOT NULL, +-- `key_data` varchar(255) DEFAULT NULL, +-- `key_hash` varchar(22) NOT NULL, +-- `key_type` enum('text','value') NOT NULL DEFAULT 'value', +-- `value_data` varchar(255) DEFAULT NULL, +-- `value_type` enum('array','data','hash','text','value') NOT NULL DEFAULT 'value', +-- PRIMARY KEY (`id`), +-- UNIQUE KEY `hash_2` (`hash`,`key_hash`) +--); +-- +--DROP TABLE IF EXISTS `rec_item`; +--CREATE TABLE `rec_item` ( +-- `id` bigint(20) NOT NULL AUTO_INCREMENT, +-- `item_type` enum('array','hash') NOT NULL DEFAULT 'hash', +-- PRIMARY KEY (`id`) +--); +-- +--DROP TABLE IF EXISTS `rec_value_data`; +--CREATE TABLE `rec_value_data` ( +-- `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, +-- `data` longblob NOT NULL, +-- PRIMARY KEY (`id`) +--); +-- +--DROP TABLE IF EXISTS `rec_value_text`; +--CREATE TABLE `rec_value_text` ( +-- `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, +-- `data` longtext NOT NULL, +-- PRIMARY KEY (`id`) +--); +-- diff --git a/lib/DBM/Deep/Engine.pm b/lib/DBM/Deep/Engine.pm index 40895dc..094f51c 100644 --- a/lib/DBM/Deep/Engine.pm +++ b/lib/DBM/Deep/Engine.pm @@ -13,18 +13,6 @@ use DBM::Deep::Iterator (); # mutex. But, it's the caller's responsability to make sure that this has # been done. -# Setup file and tag signatures. These should never change. -sub SIG_FILE () { 'DPDB' } -sub SIG_HEADER () { 'h' } -sub SIG_HASH () { 'H' } -sub SIG_ARRAY () { 'A' } -sub SIG_NULL () { 'N' } -sub SIG_DATA () { 'D' } -sub SIG_INDEX () { 'I' } -sub SIG_BLIST () { 'B' } -sub SIG_FREE () { 'F' } -sub SIG_SIZE () { 1 } - =head1 NAME DBM::Deep::Engine diff --git a/lib/DBM/Deep/Engine/File.pm b/lib/DBM/Deep/Engine/File.pm index df8cc4e..d5b60f3 100644 --- a/lib/DBM/Deep/Engine/File.pm +++ b/lib/DBM/Deep/Engine/File.pm @@ -17,6 +17,18 @@ sub sector_type { 'DBM::Deep::Sector::File' } my $STALE_SIZE = 2; +# Setup file and tag signatures. These should never change. +sub SIG_FILE () { 'DPDB' } +sub SIG_HEADER () { 'h' } +sub SIG_HASH () { 'H' } +sub SIG_ARRAY () { 'A' } +sub SIG_NULL () { 'N' } +sub SIG_DATA () { 'D' } +sub SIG_INDEX () { 'I' } +sub SIG_BLIST () { 'B' } +sub SIG_FREE () { 'F' } +sub SIG_SIZE () { 1 } + # Please refer to the pack() documentation for further information my %StP = ( 1 => 'C', # Unsigned char value (no order needed as it's just one byte)