CREATE DATABASE cell_database
DEFAULT CHARACTER SET utf8
DEFAULT COLLATE utf8_general_ci;
USE cell_database;
CREATE TABLE op (
code TINYINT UNSIGNED PRIMARY KEY,
name VARCHAR(30) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NULL ON UPDATE CURRENT_TIMESTAMP
);
CREATE TABLE bts (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
lat FLOAT( 10, 6 ) NOT NULL ,
lng FLOAT( 10, 6 ) NOT NULL,
description VARCHAR(1000),
op_code TINYINT UNSIGNED NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NULL ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (`op_code`) REFERENCES `op`(`code`)
ON DELETE CASCADE
ON UPDATE CASCADE
);
CREATE TABLE cell_2g(
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
cellid SMALLINT UNSIGNED NOT NULL,
lac SMALLINT UNSIGNED NOT NULL,
band TINYINT UNSIGNED NOT NULL,
bts_id INT(6) UNSIGNED NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NULL ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (`bts_id`) REFERENCES `bts`(`id`)
ON DELETE CASCADE
ON UPDATE CASCADE
);
CREATE TABLE cell_3g(
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
cellid INT UNSIGNED NOT NULL,
lac INT UNSIGNED NOT NULL,
rnc SMALLINT UNSIGNED NOT NULL,
psc INT UNSIGNED NOT NULL,
bts_id INT(6) UNSIGNED NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NULL ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (`bts_id`) REFERENCES `bts`(`id`)
ON DELETE CASCADE
ON UPDATE CASCADE
);
CREATE TABLE cell_4g(
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
ci INT UNSIGNED NOT NULL,
enodeb INT UNSIGNED NOT NULL,
sector TINYINT UNSIGNED NOT NULL,
pci TINYINT UNSIGNED NOT NULL,
band TINYINT UNSIGNED NOT NULL,
bts_id INT(6) UNSIGNED NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NULL ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (`bts_id`) REFERENCES `bts`(`id`)
ON DELETE CASCADE
ON UPDATE CASCADE
);
INSERT INTO op (code, name) VALUES
(10, 'Vodafone'),
(01, 'TIM'),
(88, 'Wind'),
(99, 'H3G');