CREATE TABLE `item` (
	`sku` VARCHAR(60) NOT NULL,
	`name` LONGTEXT DEFAULT NULL,
	PRIMARY KEY (`sku`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Reselling item price, not including production item price, service item price, and subscription item price
CREATE TABLE `item_price` (
	`id` INT(11) NOT NULL AUTO_INCREMENT,
	`sku` VARCHAR(60) NOT NULL,
	`type` VARCHAR(4) NOT NULL, -- buy, sell
	`currency` VARCHAR(3) NOT NULL,
	`value` INT(11) NOT NULL,
	`period` DATETIME NOT NULL,
	PRIMARY KEY (`id`),
	KEY `sku` (`sku`),
	CONSTRAINT `item_price_fk_sku`
		FOREIGN KEY (`sku`)
		REFERENCES `item`(`sku`)
		ON UPDATE CASCADE
		ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Not including assets inventory, get from buying/production, and shipping/expedition
CREATE TABLE `inventory` (
	`id` INT(11) NOT NULL AUTO_INCREMENT,
	`sku` VARCHAR(60) NOT NULL,
	`flow` VARCHAR(20) NOT NULL, -- in, out, buy, sell, buy return, sell return, use, produce
	`when` DATETIME NOT NULL,
	`qty` INT(11) NOT NULL,
	`note` LONGTEXT DEFAULT NULL,
	PRIMARY KEY (`id`),
	KEY `sku` (`sku`),
	CONSTRAINT `inventory_fk_sku`
		FOREIGN KEY (`sku`)
		REFERENCES `item`(`sku`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- get from: buying/production
