Skip to content

Instantly share code, notes, and snippets.

@Moketronics
Created February 22, 2012 20:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Moketronics/1887091 to your computer and use it in GitHub Desktop.
Save Moketronics/1887091 to your computer and use it in GitHub Desktop.
Tile store initial DB layout
CREATE TABLE tiles (
tile_id SMALLINT(5) UNSIGNED NOT NULL AUTO_INCREMENT,
tile_name VARCHAR(80) NOT NULL,
quantity SMALLINT(5) UNSIGNED NOT NULL,
old_lot_qty SMALLINT(5) UNSIGNED,
n_height FLOAT(3) UNSIGNED NOT NULL,
n_width FLOAT(3) UNSIGNED NOT NULL,
n_thick FLOAT(3) UNSIGNED NOT NULL,
e_height FLOAT(5) UNSIGNED,
e_height FLOAT(5) UNSIGNED,
local_supply TINYINT(1) NOT NULL,
sealant TINYINT(1) NOT NULL,
rating TINYINT(1) UNSIGNED NOT NULL,
date_last_updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
tile_notes TEXT,
PRIMARY KEY (tile_id)
);
CREATE TABLE manufacturer (
manu_id SMALLINT(3) UNSIGNED NOT NULL AUTO_INCREMENT,
manu_name VARCHAR(80) NOT NULL,
PRIMARY KEY (manu_id)
);
CREATE TABLE series (
series_id SMALLINT(4) UNSIGNED NOT NULL AUTO_INCREMENT,
series_name VARCHAR(80) NOT NULL,
man_id SMALLINT(3) UNSIGNED NOT NULL,
PRIMARY KEY (series_id)
);
CREATE TABLE material (
material_id SMALLINT(3) UNSIGNED NOT NULL AUTO_INCREMENT,
material_name VARCHAR(30) NOT NULL,
PRIMARY KEY (material_id)
);
CREATE TABLE colour (
colour_id SMALLINT(3) UNSIGNED NOT NULL AUTO_INCREMENT,
colour_name VARCHAR(30) NOT NULL,
PRIMARY KEY (colour_id)
);
CREATE TABLE country (
country_id SMALLINT(3) UNSIGNED NOT NULL AUTO_INCREMENT,
country_name VARCHAR(40) NOT NULL,
PRIMARY KEY (country_id)
)
CREATE TABLE colour_associations (
co_assoc_id SMALLINT(5) UNSIGNED NOT NULL AUTO_INCREMENT,
tile_id SMALLINT(5) UNSIGNED NOT NULL,
colour_id SMALLINT(3) UNSIGNED NOT NULL,
primary_colour TINYINT(1) UNSIGNED NOT NULL,
PRIMARY KEY (co_assoc_id)
);
CREATE TABLE manu_associations (
man_assoc_id SMALLINT(5) UNSIGNED NOT NULL AUTO_INCREMENT,
tile_id SMALLINT(5) UNSIGNED NOT NULL,
manu_id SMALLINT(3) UNSIGNED NOT NULL,
PRIMARY KEY (man_assoc_id)
);
CREATE TABLE series_associations (
se_assoc_id SMALLINT(5) UNSIGNED NOT NULL AUTO_INCREMENT,
tile_id SMALLINT(5) UNSIGNED NOT NULL,
series_id SMALLINT(4) UNSIGNED NOT NULL AUTO_INCREMENT,
PRIMARY KEY (se_assoc_id)
);
CREATE TABLE material_associations (
mat_assoc_id SMALLINT(5) UNSIGNED NOT NULL AUTO_INCREMENT,
tile_id SMALLINT(5) UNSIGNED NOT NULL,
material_id SMALLINT(3) UNSIGNED NOT NULL,
PRIMARY KEY (mat_assoc_id)
);
CREATE TABLE country_associations (
co_assoc_id SMALLINT(5) UNSIGNED NOT NULL AUTO_INCREMENT,
tile_id SMALLINT(5) UNSIGNED NOT NULL,
country_id SMALLINT(3) UNSIGNED NOT NULL,
PRIMARY KEY (co_assoc_id)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment