Skip to content

Instantly share code, notes, and snippets.

@y2k-shubham
Created April 10, 2018 13:19
Show Gist options
  • Select an option

  • Save y2k-shubham/66e939ff2f3c10f62c0136032199faca to your computer and use it in GitHub Desktop.

Select an option

Save y2k-shubham/66e939ff2f3c10f62c0136032199faca to your computer and use it in GitHub Desktop.
Table creation scripts for MetaData-DB
USE `meta`;
DROP TABLE IF EXISTS `dbs`;
CREATE TABLE `dbs` (
`id` INT NOT NULL AUTO_INCREMENT,
`name` VARCHAR(50) NOT NULL,
`parallelism` INT NOT NULL DEFAULT 32,
`status` BIT(1) NOT NULL DEFAULT b'1',
UNIQUE(`name`),
PRIMARY KEY (`id`)
);
DROP TABLE IF EXISTS `tables`;
CREATE TABLE `tables` (
`id` INT NOT NULL AUTO_INCREMENT,
`db_id` INT NOT NULL,
`name` VARCHAR(50) NOT NULL,
`format` VARCHAR(50) NOT NULL DEFAULT 'parquet',
`status` BIT(1) NOT NULL DEFAULT b'1',
`distribution_column` VARCHAR(50),
`last_updated` DATETIME,
PRIMARY KEY (`id`)
);
DROP TABLE IF EXISTS `columns`;
CREATE TABLE `columns` (
`id` INT NOT NULL AUTO_INCREMENT,
`table_id` INT NOT NULL,
`name` VARCHAR(50) NOT NULL,
`status` BIT(1) NOT NULL DEFAULT b'1',
`data_type` VARCHAR(50),
`default_value` VARCHAR(50),
PRIMARY KEY (`id`)
);
DROP TABLE IF EXISTS `transforms`;
CREATE TABLE `transforms` (
`id` INT NOT NULL AUTO_INCREMENT,
`table_id` INT NOT NULL,
`column` VARCHAR(50) NOT NULL,
`partition` BIT(1) NOT NULL DEFAULT b'1',
`status` BIT(1) NOT NULL DEFAULT b'1',
`function` VARCHAR(50),
`derived_column` VARCHAR(50),
`level` INT,
PRIMARY KEY (`id`)
);
===========================
GRANT
SELECT, INSERT, UPDATE, DELETE,
CREATE, ALTER, DROP
ON meta.*
TO 'meta-write'@'localhost';
GRANT
SELECT
ON meta.*
TO 'meta-read'@'localhost';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment