- /* This is here because I've been doing the following to check for errors:
-
- mysql -u root -p < file.sql */
- drop database `shop`;
-
- create schema if not exists `shop` default character set utf8;
-
- /* Use it. */
- use `shop`;
-
- /* Product-category table. */
- create table if not exists `category`
- (
- `key` int not null auto_increment,
- `name` varchar (80) not null,
- `num_products` int null, /* number of products in stock under this category. */
- primary key (`key`)
- );
-
- /* Product sub-category table. */
- create table if not exists `sub_category`
- (
- `key` int not null auto_increment,
- `name` varchar (80) not null,
- `num_products` int, /* number of products in stock under this sub-category. */
- `category_key` int, /* The category this sub-category belongs to. */
- primary key (`key`),
- foreign key (`category_key`) references category (`key`)
- );
-
- /* Manufacturer table. */
- create table if not exists `manufacturer`
- (
- `key` int not null auto_increment,
- `name` varchar(40) not null,
- `products` int, /* Products the shop buys from this manufacturer. */
- primary key (`key`)
- );
-
- /* Intermediate table, because I'd like to know the sub-categories that apply
- to each manufacturer. */
- create table if not exists `sub_categories_per_manufacturer`
- (
- `key` int not null auto_increment,
- `sub_category_key` int,
- `manufacturer_key` int,
-
- /* Number of products in stock from a given manufacturer/sub-category pair. */
- `num_products` int,
-
- primary key (`key`),
- foreign key (`sub_category_key`) references sub_category (`key`),
- foreign key (`manufacturer_key`) references manufacturer (`key`)
- );
-
- /* memory-series table. */
- create table if not exists `memory_series`
- (
- `key` int not null auto_increment,
- `name` varchar(40) not null,
- `count` int, /* Number of products in stock. */
- primary key (`key`)
- );
-
- /* memory-technology table. */
- create table if not exists `memory_technology`
- (
- `key` int not null auto_increment,
- `name` varchar(40) not null,
- `count` int, /* Number of products in stock. */
- primary key (`key`)
- );
-
- /* memory-size table. */
- create table if not exists `memory_size`
- (
- `key` int not null auto_increment,
- `name` varchar(40) not null,
- `count` int, /* Number of products in stock. */
- primary key (`key`)
- );
-
- /* memory-organization table. */
- create table if not exists `memory_organization`
- (
- `key` int not null auto_increment,
- `name` varchar(40) not null,
- `count` int, /* Number of products in stock. */
- primary key (`key`)
- );
-
- /* memory-interface table. */
- create table if not exists `memory_interface`
- (
- `key` int not null auto_increment,
- `name` varchar(40) not null,
- `count` int, /* Number of products in stock. */
- primary key (`key`)
- );
-
- /* memory-frequency table. */
- create table if not exists `memory_frequency`
- (
- `key` int not null auto_increment,
- `name` varchar(40) not null,
- `count` int, /* Number of products in stock. */
- primary key (`key`)
- );
-
- /* memory-write-cycle-time table. */
- create table if not exists `memory_write_cycle_time`
- (
- `key` int not null auto_increment,
- `name` varchar(40) not null,
- `count` int, /* Number of products in stock. */
- primary key (`key`)
- );
-
- /* memory-access-time table. */
- create table if not exists `memory_access_time`
- (
- `key` int not null auto_increment,
- `name` varchar(40) not null,
- `count` int, /* Number of products in stock. */
- primary key (`key`)
- );
-
- /* memory-voltage-supply table. */
- create table if not exists `memory_voltage_supply`
- (
- `key` int not null auto_increment,
- `name` varchar(40) not null,
- `count` int, /* Number of products in stock. */
- primary key (`key`)
- );
-
- /* memory-operating-temperature table. */
- create table if not exists `memory_operating_temperature`
- (
- `key` int not null auto_increment,
- `name` varchar(40) not null,
- `count` int, /* Number of products in stock. */
- primary key (`key`)
- );
-
- /* memory-mounting-type table. */
- create table if not exists `memory_mounting_type`
- (
- `key` int not null auto_increment,
- `name` varchar(40) not null,
- `count` int, /* Number of products in stock. */
- primary key (`key`)
- );
-
- /* memory-package table.
-
- Not sure if this should be done as foreign keys into an `ic-package' table. */
- create table if not exists `memory_package`
- (
- `key` int not null auto_increment,
- `name` varchar(80) not null,
- `count` int, /* Number of products in stock. */
- primary key (`key`)
- );
-
- /* memory-eeprom table. */
- create table if not exists `memory_eeprom`
- (
- `key` int not null auto_increment,
-
- /*
- * Part info.
- */
-
- /* Arbritrary string assigned by us, giving such product's
- part-number. */
- `part_number` varchar(40) not null,
-
- /* Arbitrary integer assigned by the manufacturer, describing such product's
- number. */
- `manufacturer_part_number` varchar(40) not null,
-
- /* An excerpt of product's name, part-number, and most notable features. */
- `description` varchar(40) not null,
-
- /* Long version of the above. */
- `detailed_description` varchar(80) not null,
-
- /*
- * Media options
- */
-
- /* Product's image. */
- `picture` mediumblob,
-
- /* Product's datasheet. */
- `data_sheet` mediumblob,
-
- /* Some CAD model. */
- `eda_model` mediumblob,
-
- /*
- * Environmental options
- */
-
- /* Whether this product is ROHS compilant. */
- `rohs_compilant_p` boolean,
-
- /* Classified moisture-sensivity level. */
- `moisture_sensitivity_level` char,
-
- /* I don't know what these stand for. */
- `reach_status` varchar(40),
- `eccn` varchar(40),
- `htsus` varchar(40),
-
- /* Manufacturer or supplier's lead time for this product, in weeks. */
- `lead_time` int,
-
- /* Bulk packaging, in units */
- `standard_packaging` int,
-
- /*
- * Stocking stuff
- */
- `stock_type` enum ('in-stock', 'normally-stocking', 'new-product'),
- `quantity_available` int unsigned,
-
- /* Unitary price */
- `price` decimal (10, 6),
-
- /* Foreign key into the `manufacturer's table. */
- `manufacturer` int,
-
- /* Foreign key into the `memory-series' table. */
- `series` int,
-
- /* Product status. */
- `product_status` enum ('active', 'not-for-new-designs', 'obsolete', \
- 'discontinued-by-us'),
-
- /* Foreign key into the `memory-technology' table. */
- `technology` int,
-
- /* Foregin key into the `memory-size' table. */
- `memory_size` int,
-
- /* Foreign key into the `memory-organization' table. */
- `memory_organization` int,
-
- /* Foregin key into the `memory-interface' table. */
- `memory_interface` int,
-
- /* Foreign key into the `memory-frequency' table. */
- `clock_frequency` int,
-
- /* Foreign key into the `memory-write-cycle-time' table. */
- `write_cycle_time` int,
-
- /* Foreign key into the `memory-access-time' table. */
- `access_time` int,
-
- /* Foreign key into the `memory-voltage-supply'. */
- `voltage_supply` int,
-
- /* Foreign key into the `memory-operating-temperature' table. */
- `operating_temperature` int,
-
- /* Foreign key into the `memory-mounting-type' table. */
- `mounting_type` int,
-
- /* Foreign key into the `ic-package' table. */
- `package` int,
-
- /* Key definitions. */
- primary key (`key`),
-
- foreign key (`manufacturer`) references manufacturer (`key`),
- foreign key (`series`) references memory_series (`key`),
- foreign key (`technology`) references memory_technology (`key`),
- foreign key (`memory_size`) references memory_size (`key`),
- foreign key (`memory_organization`) references memory_organization (`key`),
- foreign key (`memory_interface`) references memory_interface (`key`),
- foreign key (`clock_frequency`) references memory_frequency (`key`),
- foreign key (`write_cycle_time`) references memory_write_cycle_time (`key`),
- foreign key (`access_time`) references memory_access_time (`key`),
- foreign key (`voltage_supply`) references memory_voltage_supply (`key`),
- foreign key (`operating_temperature`) references memory_operating_temperature (`key`),
- foreign key (`mounting_type`) references memory_mounting_type (`key`),
- foreign key (`package`) references memory_package (`key`)
- );