Field possible database changes

The current format of the database is good for small amounts of data. The truth is that the hashes and sizes of the files are what really determine if a file is different or not. After chatting with Obiwantje about this, I'm beginning some code tests with a hash-centric database model, instead of the game/rom centric. This means that each hash can have mutliple roms attached to it, similarly a given game can have multiple sources or systems attached. It's a much cleaner system, but demands a total rewrite and new databae structure.
This commit is contained in:
Matt Nadareski
2016-04-21 23:46:14 -07:00
parent e0b0071847
commit dbbf297263
2 changed files with 153 additions and 0 deletions

View File

@@ -106,6 +106,65 @@ CREATE TABLE IF NOT EXISTS data (
SqliteCommand slc = new SqliteCommand(query, dbc);
slc.ExecuteNonQuery();
}
else if (type == "SabreTools")
{
string query = @"
CREATE TABLE IF NOT EXISTS hash (
'id' INTEGER PRIMARY KEY NOT NULL,
'size' INTEGER NOT NULL DEFAULT -1,
'crc' TEXT NOT NULL,
'md5' TEXT NOT NULL,
'sha1' TEXT NOT NULL
)";
SqliteCommand slc = new SqliteCommand(query, dbc);
slc.ExecuteNonQuery();
query = @"
CREATE TABLE IF NOT EXISTS hashdata (
'hashid' INTEGER NOT NULL,
'key' TEXT NOT NULL,
'value' TEXT,
PRIMARY KEY (hashid, key, value)
)";
slc = new SqliteCommand(query, dbc);
slc.ExecuteNonQuery();
query = @"
CREATE TABLE IF NOT EXISTS source (
'id' INTEGER PRIMARY KEY NOT NULL,
'name' TEXT NOT NULL UNIQUE,
'url' TEXT NOT NULL
)";
slc = new SqliteCommand(query, dbc);
slc.ExecuteNonQuery();
query = @"
CREATE TABLE IF NOT EXISTS system (
'id' INTEGER PRIMARY KEY NOT NULL,
'manufacturer' TEXT NOT NULL,
'name' TEXT NOT NULL
)";
slc = new SqliteCommand(query, dbc);
slc.ExecuteNonQuery();
query = @"
CREATE TABLE IF NOT EXISTS gamesystem (
'game' TEXT NOT NULL,
'systemid' INTEGER NOT NULL,
PRIMARY KEY (game, systemid)
)";
slc = new SqliteCommand(query, dbc);
slc.ExecuteNonQuery();
query = @"
CREATE TABLE IF NOT EXISTS gamesource (
'game' TEXT NOT NULL,
'sourceid' INTEGER NOT NULL,
PRIMARY KEY (game, sourceid)
)";
slc = new SqliteCommand(query, dbc);
slc.ExecuteNonQuery();
}
}
catch (Exception ex)
{