Skip to content

Instantly share code, notes, and snippets.

@Moketronics
Created February 23, 2012 18:34
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/1894253 to your computer and use it in GitHub Desktop.
Save Moketronics/1894253 to your computer and use it in GitHub Desktop.
Tile store initial DB layout revised
CREATE TABLE tiles (
tile_id INT(6) UNSIGNED NOT NULL AUTO_INCREMENT,
tile_name TEXT NOT NULL,
quantity INT(6) UNSIGNED NOT NULL,
old_lot_qty INT(6) UNSIGNED,
nom_height DECIMAL(6,3) UNSIGNED NOT NULL,
nom_width DECIMAL(6,3) UNSIGNED NOT NULL,
nom_thick DECIMAL(6,3) UNSIGNED NOT NULL,
exact_height INT(6) UNSIGNED,
exact_width INT(6) UNSIGNED,
local_supply TINYINT(1) NOT NULL,
rating TINYINT(1) UNSIGNED NOT NULL,
date_last_modified TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
tile_notes TEXT,
PRIMARY KEY (tile_id)
);
CREATE TABLE manufacturer (
manufacturer_id INT(6) UNSIGNED NOT NULL AUTO_INCREMENT,
manufacturer_name TEXT NOT NULL,
PRIMARY KEY (manufacturer_id)
);
CREATE TABLE series (
series_id INT(6) UNSIGNED NOT NULL AUTO_INCREMENT,
series_name TEXT NOT NULL,
manufacturer_id INT(6) UNSIGNED NOT NULL,
PRIMARY KEY (series_id)
);
CREATE TABLE material (
material_id INT(6) UNSIGNED NOT NULL AUTO_INCREMENT,
material_name TEXT NOT NULL,
PRIMARY KEY (material_id)
);
CREATE TABLE colour (
colour_id INT(6) UNSIGNED NOT NULL AUTO_INCREMENT,
colour_name TEXT NOT NULL,
PRIMARY KEY (colour_id)
);
CREATE TABLE sealant (
sealant_id INT(6) UNSIGNED NOT NULL AUTO_INCREMENT,
sealant_name TEXT NOT NULL,
PRIMARY KEY (sealant_id)
);
CREATE TABLE country (
country_id INT(6) UNSIGNED NOT NULL AUTO_INCREMENT,
country_name TEXT NOT NULL,
PRIMARY KEY (country_id)
)
CREATE TABLE colour_associations (
colour_assoc_id INT(6) UNSIGNED NOT NULL AUTO_INCREMENT,
tile_id INT(6) UNSIGNED NOT NULL,
colour_id INT(6) UNSIGNED NOT NULL,
b_primary_colour TINYINT(1) UNSIGNED NOT NULL,
PRIMARY KEY (colour_assoc_id)
);
CREATE TABLE manufacturer_associations (
manufacturer_assoc_id INT(6) UNSIGNED NOT NULL AUTO_INCREMENT,
tile_id INT(6) UNSIGNED NOT NULL,
manufacturer_id INT(6) UNSIGNED NOT NULL,
PRIMARY KEY (manufacturer_assoc_id)
);
CREATE TABLE series_associations (
series_assoc_id INT(6) UNSIGNED NOT NULL AUTO_INCREMENT,
tile_id INT(6) UNSIGNED NOT NULL,
series_id INT(6) UNSIGNED NOT NULL,
PRIMARY KEY (series_assoc_id)
);
CREATE TABLE material_associations (
mataterial_assoc_id INT(6) UNSIGNED NOT NULL AUTO_INCREMENT,
tile_id INT(6) UNSIGNED NOT NULL,
material_id INT(6) UNSIGNED NOT NULL,
PRIMARY KEY (material_assoc_id)
);
CREATE TABLE sealant_associations (
sealant_assoc_id INT(6) UNSIGNED NOT NULL AUTO_INCREMENT,
tile_id INT(6) UNSIGNED NOT NULL,
sealant_id INT(6) UNSIGNED NOT NULL,
PRIMARY KEY (sealant_assoc_id)
);
CREATE TABLE country_associations (
country_assoc_id INT(6) UNSIGNED NOT NULL AUTO_INCREMENT,
tile_id INT(6) UNSIGNED NOT NULL,
country_id INT(6) UNSIGNED NOT NULL,
PRIMARY KEY (country_assoc_id)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment