text stringlengths 6 9.38M |
|---|
/*
Navicat MySQL Data Transfer
Source Server : 本地
Source Server Type : MySQL
Source Server Version : 50553
Source Host : localhost:3306
Source Schema : motion
Target Server Type : MySQL
Target Server Version : 50553
File Encoding : 65001
Date: 18/04/2019 18:18:42
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for system_menu
-- ----------------------------
DROP TABLE IF EXISTS `system_menu`;
CREATE TABLE `system_menu` (
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`pid` bigint(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT '父id',
`title` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '名称',
`node` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '节点代码',
`icon` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '菜单图标',
`url` varchar(400) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '链接',
`params` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '链接参数',
`target` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '_self' COMMENT '链接打开方式',
`sort` int(11) UNSIGNED NULL DEFAULT 0 COMMENT '菜单排序',
`status` tinyint(1) UNSIGNED NOT NULL DEFAULT 1 COMMENT '状态(0:禁用,1:启用)',
`create_by` bigint(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建人',
`create_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE,
INDEX `index_system_menu_node`(`node`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 72 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '系统菜单表' ROW_FORMAT = Compact;
-- ----------------------------
-- Records of system_menu
-- ----------------------------
INSERT INTO `system_menu` VALUES (1, 0, '系统设置', '', '', '#', '', '_self', 9000, 1, 10000, '2018-01-19 15:27:00');
INSERT INTO `system_menu` VALUES (2, 10, '后台菜单', '', 'fa fa-leaf', 'admin/menu/index', '', '_self', 10, 1, 10000, '2018-01-19 15:27:17');
INSERT INTO `system_menu` VALUES (3, 10, '系统参数', '', 'fa fa-modx', 'admin/config/index', '', '_self', 20, 1, 10000, '2018-01-19 15:27:57');
INSERT INTO `system_menu` VALUES (4, 11, '访问授权', '', 'fa fa-group', 'admin/auth/index', '', '_self', 20, 1, 10000, '2018-01-22 11:13:02');
INSERT INTO `system_menu` VALUES (5, 11, '用户管理', '', 'fa fa-user', 'admin/user/index', '', '_self', 10, 1, 0, '2018-01-23 12:15:12');
INSERT INTO `system_menu` VALUES (6, 11, '访问节点', '', 'fa fa-fort-awesome', 'admin/node/index', '', '_self', 30, 1, 0, '2018-01-23 12:36:54');
INSERT INTO `system_menu` VALUES (7, 0, '后台首页', '', '', 'admin/index/main', '', '_self', 1000, 1, 0, '2018-01-23 13:42:30');
INSERT INTO `system_menu` VALUES (8, 16, '系统日志', '', 'fa fa-code', 'admin/log/index', '', '_self', 10, 1, 0, '2018-01-24 13:52:58');
INSERT INTO `system_menu` VALUES (9, 10, '文件存储', '', 'fa fa-stop-circle', 'admin/config/file', '', '_self', 30, 1, 0, '2018-01-25 10:54:28');
INSERT INTO `system_menu` VALUES (10, 1, '系统管理', '', '', '#', '', '_self', 200, 1, 0, '2018-01-25 18:14:28');
INSERT INTO `system_menu` VALUES (11, 1, '访问权限', '', '', '#', '', '_self', 300, 1, 0, '2018-01-25 18:15:08');
INSERT INTO `system_menu` VALUES (16, 1, '日志管理', '', '', '#', '', '_self', 400, 1, 0, '2018-02-10 16:31:15');
INSERT INTO `system_menu` VALUES (17, 0, '微信管理', '', '', '#', '', '_self', 8000, 1, 0, '2018-03-06 14:42:49');
INSERT INTO `system_menu` VALUES (18, 17, '公众号配置', '', '', '#', '', '_self', 0, 1, 0, '2018-03-06 14:43:05');
INSERT INTO `system_menu` VALUES (19, 18, '微信授权绑定', '', 'fa fa-cog', 'wechat/config/index', '', '_self', 0, 1, 0, '2018-03-06 14:43:26');
INSERT INTO `system_menu` VALUES (20, 18, '关注默认回复', '', 'fa fa-comment-o', 'wechat/keys/subscribe', '', '_self', 0, 1, 0, '2018-03-06 14:44:45');
INSERT INTO `system_menu` VALUES (21, 18, '无反馈默认回复', '', 'fa fa-commenting', 'wechat/keys/defaults', '', '_self', 0, 1, 0, '2018-03-06 14:45:55');
INSERT INTO `system_menu` VALUES (22, 18, '微信关键字管理', '', 'fa fa-hashtag', 'wechat/keys/index', '', '_self', 0, 1, 0, '2018-03-06 14:46:23');
INSERT INTO `system_menu` VALUES (23, 17, '微信服务定制', '', '', '#', '', '_self', 0, 1, 0, '2018-03-06 14:47:11');
INSERT INTO `system_menu` VALUES (24, 23, '微信菜单管理', '', 'fa fa-gg-circle', 'wechat/menu/index', '', '_self', 0, 1, 0, '2018-03-06 14:47:39');
INSERT INTO `system_menu` VALUES (25, 23, '微信图文管理', '', 'fa fa-map-o', 'wechat/news/index', '', '_self', 0, 1, 0, '2018-03-06 14:48:14');
INSERT INTO `system_menu` VALUES (26, 17, '微信粉丝管理', '', 'fa fa-user', '#', '', '_self', 0, 1, 0, '2018-03-06 14:48:33');
INSERT INTO `system_menu` VALUES (27, 26, '微信粉丝列表', '', 'fa fa-users', 'wechat/fans/index', '', '_self', 20, 1, 0, '2018-03-06 14:49:04');
INSERT INTO `system_menu` VALUES (28, 26, '微信黑名单管理', '', 'fa fa-user-times', 'wechat/fans_block/index', '', '_self', 30, 1, 0, '2018-03-06 14:49:22');
INSERT INTO `system_menu` VALUES (29, 26, '微信标签管理', '', 'fa fa-tags', 'wechat/tags/index', '', '_self', 10, 1, 0, '2018-03-06 14:49:39');
INSERT INTO `system_menu` VALUES (32, 0, '商城管理', '', '', '#', '', '_self', 2000, 0, 0, '2018-03-20 16:46:07');
INSERT INTO `system_menu` VALUES (33, 32, '商品管理', '', '', '#', '', '_self', 0, 0, 0, '2018-03-20 16:46:21');
INSERT INTO `system_menu` VALUES (34, 33, '产品管理', '', 'fa fa-modx', 'store/goods/index', '', '_self', 0, 0, 0, '2018-03-20 16:46:45');
INSERT INTO `system_menu` VALUES (35, 33, '规格管理', '', 'fa fa-hashtag', 'store/goods_spec/index', '', '_self', 0, 0, 0, '2018-03-20 16:47:08');
INSERT INTO `system_menu` VALUES (36, 33, '分类管理', '', 'fa fa-product-hunt', 'store/goods_cate/index', '', '_self', 0, 0, 0, '2018-03-20 16:47:50');
INSERT INTO `system_menu` VALUES (37, 33, '品牌管理', '', 'fa fa-scribd', 'store/goods_brand/index', '', '_self', 0, 0, 0, '2018-03-20 16:48:05');
INSERT INTO `system_menu` VALUES (38, 32, '订单管理', '', '', '#', '', '_self', 0, 0, 0, '2018-04-21 15:07:36');
INSERT INTO `system_menu` VALUES (39, 38, '订单列表', '', 'fa fa-adjust', 'store/order/index', '', '_self', 0, 0, 0, '2018-04-21 15:07:54');
INSERT INTO `system_menu` VALUES (40, 32, '商城配置', '', '', '#', '', '_self', 0, 0, 0, '2018-04-21 15:08:17');
INSERT INTO `system_menu` VALUES (41, 40, '参数管理', '', '', '#', '', '_self', 0, 0, 0, '2018-04-21 15:08:25');
INSERT INTO `system_menu` VALUES (42, 40, '快递公司', '', 'fa fa-mixcloud', 'store/express/index', '', '_self', 0, 0, 0, '2018-04-21 15:08:50');
INSERT INTO `system_menu` VALUES (43, 0, '编写计划', '', '', '#', '', '_self', 3000, 1, 0, '2018-11-18 20:30:42');
INSERT INTO `system_menu` VALUES (44, 43, '动作库管理', '', '', '#', '', '_self', 0, 1, 0, '2018-11-18 20:33:12');
INSERT INTO `system_menu` VALUES (45, 44, '动作库列表', '', 'fa fa-child', 'motion/motion/index', '', '_self', 0, 1, 0, '2018-11-18 20:33:36');
INSERT INTO `system_menu` VALUES (46, 44, '动作库类型', '', 'fa fa-square-o', 'motion/motion_type/index', '', '_self', 0, 1, 0, '2018-11-20 20:52:54');
INSERT INTO `system_menu` VALUES (50, 43, '会员管理', '', '', '#', '', '_self', 0, 1, 0, '2018-11-22 16:17:37');
INSERT INTO `system_menu` VALUES (51, 50, '会员列表', '', '', 'motion/member/index', '', '_self', 0, 1, 0, '2018-11-22 16:19:57');
INSERT INTO `system_menu` VALUES (52, 43, '教练管理', '', '', '#', '', '_self', 0, 1, 0, '2018-11-22 16:35:42');
INSERT INTO `system_menu` VALUES (53, 52, '教练列表', '', '', 'motion/coach/index', '', '_self', 0, 1, 0, '2018-11-22 16:35:54');
INSERT INTO `system_menu` VALUES (56, 43, '备课管理', '', '', '#', '', '_self', 0, 1, 0, '2018-11-23 15:10:38');
INSERT INTO `system_menu` VALUES (57, 56, '会员管理', '', '', 'motion/lesson/index', '', '_self', 0, 1, 0, '2018-11-23 15:10:53');
INSERT INTO `system_menu` VALUES (58, 56, '我的会员', '', '', 'motion/lesson/my', '', '_self', 0, 1, 0, '2018-11-25 10:46:23');
INSERT INTO `system_menu` VALUES (59, 43, '留言管理', '', '', '#', '', '_self', 0, 0, 0, '2018-11-28 11:42:34');
INSERT INTO `system_menu` VALUES (60, 59, '全部留言', '', '', 'motion/message/index', '', '_self', 0, 0, 0, '2018-11-28 11:43:18');
INSERT INTO `system_menu` VALUES (62, 56, '批量备课', '', '', '/motion/lesson/batch', '', '_self', 0, 1, 0, '2019-03-02 18:15:23');
INSERT INTO `system_menu` VALUES (63, 0, '私教管理', '', '', '#', '', '_self', 0, 1, 0, '2019-04-10 14:11:04');
INSERT INTO `system_menu` VALUES (64, 63, '会员管理', '', '', '#', '', '_self', 0, 1, 0, '2019-04-10 14:11:54');
INSERT INTO `system_menu` VALUES (65, 64, '会员列表', '', '', 'pt/member/index', '', '_self', 0, 1, 0, '2019-04-10 14:14:12');
INSERT INTO `system_menu` VALUES (66, 63, '项目管理', '', '', '#', '', '_self', 0, 1, 0, '2019-04-12 14:08:11');
INSERT INTO `system_menu` VALUES (67, 66, '项目列表', '', '', 'pt/product/index', '', '_self', 0, 1, 0, '2019-04-12 14:13:35');
INSERT INTO `system_menu` VALUES (68, 63, '课程管理', '', '', '#', '', '_self', 0, 1, 0, '2019-04-12 15:37:50');
INSERT INTO `system_menu` VALUES (69, 68, '团课列表', '', '', 'pt/course/index', '', '_self', 0, 1, 0, '2019-04-12 15:38:27');
INSERT INTO `system_menu` VALUES (70, 68, '课程日程', '', '', 'pt/classes/schedule', '', '_self', 0, 1, 0, '2019-04-12 15:51:23');
INSERT INTO `system_menu` VALUES (71, 68, '课程列表', '', '', 'pt/classes/index', '', '_self', 0, 1, 0, '2019-04-18 13:52:18');
SET FOREIGN_KEY_CHECKS = 1;
|
-- Delete data from tables
DELETE FROM `PrivateSchool`.`students_in_courses`;
DELETE FROM `PrivateSchool`.`assignments_in_courses`;
DELETE FROM `PrivateSchool`.`trainers_in_courses`;
DELETE FROM `PrivateSchool`.`students`;
DELETE FROM `PrivateSchool`.`trainers`;
DELETE FROM `PrivateSchool`.`assignments`;
DELETE FROM `PrivateSchool`.`courses`; |
DROP TABLE IF EXISTS `XXX_papoo_imex_daten`; ##b_dump##
|
select smr.id, smr.seminar_type_id, smr.name, smt.name, smr.studio_id, smr.studio_name,
(case when smr.technolog_id is not null then smr.technolog_id || '' else
(case when smr.partimer_id is not null then smr.partimer_id || '' else
(case when smr.partner_id is not null then smr.partner_id || '' else
(case when smr.beauty_consultant_id is not null then smr.beauty_consultant_id end) end) end ) end ) as educater_id,
smr.started_at, smr.closed_at, smr.salon_id, smr.is_closed , usr.lname || ' ' || usr.fname
from seminars as smr
left join users as usr on (case when smr.technolog_id is not null then smr.technolog_id || '' else
(case when smr.partimer_id is not null then smr.partimer_id || '' else
(case when smr.partner_id is not null then smr.partner_id || '' else
(case when smr.beauty_consultant_id is not null then smr.beauty_consultant_id end) end) end ) end ) = usr.id || ''
left join seminar_types as smt ON smr.seminar_type_id = smt.id
order by 1 |
create table dunce_table
(
id int auto_increment,
player varchar(16) null,
uuid varchar(36) null,
disconnect_count int default 0 null,
constraint dunce_table_pk
primary key (id)
);
create index dunce_table_uuid_index
on dunce_table (uuid);
|
USE burgers_db;
INSERT INTO burgers (burger_name) VALUE
("cheese Burger"),
("Double Cheeseburger")
; |
CREATE DATABASE People
USE People
CREATE TABLE People(
Id INT PRIMARY KEY IDENTITY,
[Name] NVARCHAR(100) NOT NULL,
Birthday SMALLDATETIME NOT NULL
)
INSERT INTO People([Name],Birthday)
VALUES
('Victor','2000-12-07 00:00:00.000'),
('Steven','1992-09-10 00:00:00.000'),
('Stephen','1910-09-19 00:00:00.000'),
('John','2010-01-06 00:00:00.000')
SELECT [Name],
DATEDIFF(YEAR,Birthday,GETDATE()) AS [Age in Years],
DATEDIFF(MONTH,Birthday,GETDATE()) AS [Age in Months],
DATEDIFF(DAY,Birthday,GETDATE()) AS [Age in Days],DATEDIFF(MINUTE,Birthday,
GETDATE()) AS [Age in Minutes]
FROM People |
INSERT INTO contacts(contact_id,first_Name,last_Name,group_Code,mail_Id,mobile_Number)
VALUES(101,'lal','lalu','FAMILY','lal@gmail.com','1234567890'); |
CREATE TABLE blogs (
id SERIAL8 PRIMARY KEY,
title TEXT,
copy TEXT,
photo TEXT,
mood TEXT
); |
--1
select count (*) from person p
where p.height is null;
--ans 47315
--2
select count (*) from (
select m.id from movie m
join involved i on m.id = i.movieid
join person p on i.personid = p.id
group by m.id
having avg(p.height) > 190
) m;
--ans 89
--3
select count (*) from (
select m.id from movie m
join movie_genre mg on mg.movieid = m.id
group by m.id, mg.genre
having count (m.id) > 1
) m;
--ans 174
--fixed version
select count (distinct m.id) from (
select m.id from movie m
join movie_genre mg on mg.movieid = m.id
group by m.id, mg.genre
having count (m.id) > 1
) m;
--ans 143
--4
select count (distinct v2.personid) from (
select v.movieid as moviesByThatGuy from person p
join involved v on v.personid = p.id
where p.name = 'Steven Spielberg' and v.role = 'director'
) movieWithThatDirector
join involved v2 on v2.movieid = movieWithThatDirector.moviesByThatGuy
where role = 'actor';
--ans 2219
--5
select
(select count (*) from movie m
where m.year = 1999) -
(select count (num) from(
select count (*) from involved i
join movie m on i.movieid = m.id
where m.year = 1999
group by m.id
) as num) moviesWithNoEntries;
--ans 7
--6
select count (*) from (
select p.id from person p
join involved i on p.id = i.personid
join involved i2 on i.personid = i2.personid
where i2.role = 'director'
and i.role = 'actor'
and i.movieid = i2.movieid
group by p.id
having count (*) > 1
) as selfDirectors;
--ans 345
--7
select count (*) from (
select count(*) from(
select m.id, i.role, count(*)
from movie m
join involved i on i.movieid = m.id
group by m.id, i.role
having m.year = '1999'
) as numberOfRolesForEachMovieFromThatYear
group by id
having count(*) >= (
select count(*) from role
)
) numberOfMoviesWithAllRoles
--ans 250
--8
select count (*) from (
select a.personid, count(*) from (
select i.personid, g.genre from involved i
join movie m on m.id = i.movieid
join movie_genre mg on mg.movieid = m.id
join genre g on g.genre = mg.genre
group by i.personid, g.genre
having g.category = 'Lame'
order by i.personid
) as a
group by a.personid
having a.count = (
select count (*) from genre g
where g.category = 'Lame'
)
) as b
--ans 1 |
INSERT INTO series (id, title, author_id, subgenre_id) VALUES
(1, "First series", 3, 1),
(2, "Second series", 2, 2);
INSERT INTO books (id, title, year, series_id) VALUES
(1, "Harry Potter and the Philosopher's Stone", 2001, 1),
(2, "Harry Potter and the Chamber of Secrets", 2002, 1),
(3, "Harry Potter and the Prisoner of Azkaban", 2004, 1),
(4, "Harry Potter and the Goblet of Fire", 2005, 1),
(5, "Harry Potter and the Order of the Phoenix", 2007, 1),
(6, "Harry Potter and the Half-Blood Prince", 2009, 1);
INSERT INTO characters (id, name, species, motto, series_id, author_id) VALUES
(1, "Harry", "Wizard", "Gotcha, Volde", 1, 1),
(2, "Ron", "Wizard", "Woo, Hermoine", 1, 1),
(3, "Hermoine", "Wizard", "I love learning", 1, 1),
(4, "Voldemort", "Wizard", "Grr", 1, 1),
(5, "Dumbeldore", "Wizard", "Love is life", 1, 1),
(6, "Snape", "Wizard", "Snape, Snape, Severus Snape", 1, 1),
(7, "Hagrid", "Wizard", "Spiders are friends", 1, 1),
(8, "Malfoy", "Wizard", "Ugh, muggles", 1, 1);
INSERT INTO subgenres (id, name) VALUES
(1, "Magic"),
(2, "Science");
INSERT INTO authors (id, name) VALUES
(1, "JK Rowling"),
(2, "Brian Cox");
INSERT INTO character_books (id, book_id, character_id) VALUES
(1, 1, 1),
(2, 2, 1),
(3, 1, 2),
(4, 2, 1),
(5, 3, 2),
(6, 3, 3),
(7, 4, 2),
(8, 4, 1),
(9, 3, 1),
(10, 6, 3),
(11, 2, 4),
(12, 9, 2),
(13, 9, 4),
(14, 3, 5),
(15, 7, 2),
(16, 8, 2);
|
/*
INSERT STATEMENT
WS NEW CATEGORY - NEW SUBCATEGORY - NEW PROVIDER - NEW ADDRESS - NEW BRANCHES
*/
INSERT INTO categories(category_name) VALUES ('Health'), ('Cosmetic'), ('Medicine'), ('Mechanic'), ('Computer');
INSERT INTO subcategories(category_id,subcategory_name) VALUES
(1,'Spa'), (1,'Massage'), (1,'Tanning'), (2,'Haircut'), (2,'Hairstyling'), (2,'Manicure'), (2,'Pedicure'), (2,'Dentist'),
(3,'Proctologist'), (3,'Clinic'), (3,'Cardiologist'),(4,'Car'),(4,'Bicicles'), (4,'Airplanes'),(4,'Motorboats'),
(5,'Laptop'),(5,'Webpage'),(5,'PersonalPC');
INSERT INTO businesses(category_id,business_name,owner_name,email,password,business_state,creation_date,last_update) VALUES
(1,'Free Spa','Ramon Gonzalez','free_spa@mail.com','12345678','ACTIVE',NOW(),NOW()), (3,'Hospital Muñiz','Esteban Callone','hospital.muniz@mail.com','12345678','ACTIVE',NOW(),NOW()),
(3,'Sanatorio Tortuga','Romina Castilla','rcastilla@mail.com','12345678','ACTIVE',NOW(),NOW());
INSERT INTO addresses(street,street_nbr,floor,postalCode,district,city,province,country,coordenates) VALUES
('Av. Rivadavia', '6800',null,'C1406',null, 'Ciudad Autonoma de Buenos Aires', 'Buenos Aires', 'AR','-34.628518:-58.461035'),
('Av. Corrientes', '3506',null,'C1194',null, 'Ciudad Autonoma de Buenos Aires','Buenos Aires', 'AR','-34.60403:-58.41470'),
('Estomba', '3924',null,'C1430',null, 'Ciudad Autonoma de Buenos Aires','Buenos Aires', 'AR','-34.553993:-58.484161'),
('Lavalle', '1514',null,'C1048',null, 'Ciudad Autonoma de Buenos Aires','Buenos Aires', 'AR','-34.60291:-58.38842'),
('Córdoba', '3845',null,'S2002LAG',null, 'Rosario', 'Santa Fe', 'AR','-32.93961:-60.675089'),
('Av. 19', '135',null,'B1902',null, 'La Plata', 'Buenos Aires', 'AR','-34.91416:-57.978332'),
('Rosario', '68',null,'C1424',null, 'Ciudad Autonoma de Buenos Aires', 'Buenos Aires', 'AR','-34.6184392:-58.4295427');
INSERT INTO branches(business_id, address_id, telephone, branch_state) VALUES
(1,5,'(03537) 41 - 5777','ACTIVE'),
(1,6,'(3243) 32 - 5772','ACTIVE'),
(2,1,'(11) 4432 - 5772','ACTIVE'),
(2,4,'(11) 6543 - 5727','ACTIVE'),
(2,3,'(11) 4956 - 5277','INACTIVE'),
(3,2,'(11) 4431 - 5777','ACTIVE');
/***
Validar que la categoria del provedor posea como subcategoria la misma subcategoria que se elegi como subcategoria del servicio
Mirar con el branch_id quien es el provedor_id en branches,
con el provider_id mirar cual es el category_id
y verificar que el subcategory que se intenta insertar en
services pertenezca a uno de los que esta dentro de subcategory
la subcategoria deberia matchear con el id de categoria que tiene el provedor de servicio
***/
INSERT INTO services (branch_id, subcategory_id, service_name, service_duration, service_state) VALUES
(1,1,'One Hour Spa',12,'ACTIVE'),
(1,2,'Swedish Massage',6,'ACTIVE'),
(1,3,'Trump Tanning',2,'ACTIVE'),
(2,1,'Spa from Home',4,'ACTIVE'),
(2,3,'Tanner Tans',3,'ACTIVE'),
(3,9,'Procto Amigo',3,'ACTIVE'),
(3,10,'MediClinic',4,'ACTIVE'),
(3,11,'Un nuevo corazon',6,'ACTIVE'),
(4,9,'Proctologo Clinic',3,'ACTIVE'),
(4,10,'Spiderman Clinic',3,'ACTIVE'),
(4,11,'Implantes cardios',12,'ACTIVE'),
(5,9,'Proctologa Brenda',4,'ACTIVE'),
(5,11,'Cardiologia',6,'ACTIVE'),
(6,11,'Cardiologos Bonairenses',12,'ACTIVE');
INSERT INTO personal_schedules (service_id, sunday, monday, tuesday, wednesday, thursday, friday, saturday, personal_state) VALUES
(1,'0000:0000','0900:1800','0900:1800','0900:1800','0900:1800','0900:1800','0000:0000','ACTIVE'),
(1,'0000:0000','0900:1800','0900:1800','0900:1800','0900:1800','0900:1800','0000:0000','ACTIVE'),
(2,'0800:1800','0800:1800','0000:0000','0800:1800','0800:1800','0000:0000','0800:1800','ACTIVE'),
(2,'0800:1800','0000:0000','0945:1915','0900:1400','0900:1800','0900:1800','0000:0000','ACTIVE'),
(2,'0800:1800','0930:1800','1000:1700','1100:1800','0900:1800','0900:1800','0800:1200','ACTIVE'),
(2,'0000:0000','0900:1800','0000:0800','0900:1800','0900:1800','0000:0000','0000:0000','ACTIVE'),
(3,'0000:0000','0900:1800','0000:0800','0900:1800','0900:1800','0000:0000','0000:0000','ACTIVE'),
(4,'0200:2300','0000:0000','0200:2300','0000:0000','0200:2300','0000:0000','0200:2300','ACTIVE'),
(4,'1400:0000','0900:1200','0900:1800','0900:1800','0900:1800','0900:1800','0000:0000','ACTIVE'),
(4,'1000:2000','0900:1800','0000:0000','0900:1800','0900:1800','0900:1100','0000:0000','ACTIVE'),
(5,'0000:0000','0900:1800','0900:1800','0900:1800','0900:1800','0900:1800','0000:0000','ACTIVE'),
(5,'0000:0000','0900:1800','0900:1800','0900:1800','0900:1800','0900:1800','0000:0000','ACTIVE'),
(5,'0000:0000','0900:1800','0900:1800','0900:1800','0900:1800','0900:1800','0000:0000','ACTIVE'),
(6,'0000:0000','0900:1700','0900:1700','0900:1700','0900:1700','0900:1700','0000:0000','ACTIVE'),
(6,'0000:0000','0800:1600','0800:1600','0800:1600','0800:1600','0800:1600','0000:0000','ACTIVE'),
(7,'0000:0000','0900:1800','0900:1800','0900:1800','0900:1800','0000:0000','0000:0000','ACTIVE'),
(7,'0000:0000','0900:1800','0900:1800','0900:1800','0900:1800','0000:0000','0000:0000','ACTIVE'),
(8,'0000:0000','0000:0000','0000:0000','0900:1800','0900:1800','0900:1800','0900:1800','ACTIVE'),
(8,'0000:0000','0000:0000','0000:0000','0900:1800','0900:1800','0900:1800','0900:1800','ACTIVE'),
(8,'0000:0000','0000:0000','0900:1800','0900:1800','0900:1800','0900:1800','0000:0000','ACTIVE'),
(8,'0000:0000','0000:0000','0900:1800','0900:1800','0900:1800','0900:1800','0000:0000','ACTIVE'),
(9,'0000:0000','0700:1600','0900:1800','0900:1800','0900:1800','0900:1800','0000:0000','ACTIVE'),
(10,'0000:0000','0900:1800','0900:1800','0900:1800','0900:1800','0900:1800','0000:0000','ACTIVE'),
(10,'0000:0000','0900:1800','0900:1800','0900:1800','0900:1800','0900:1800','0000:0000','ACTIVE'),
(10,'0000:0000','0900:1800','0900:1800','0900:1800','0900:1800','0900:1800','0000:0000','ACTIVE'),
(11,'0000:0000','0900:1800','0900:1800','0900:1800','0900:1800','0900:1800','0000:0000','ACTIVE'),
(11,'0000:0000','0900:1800','0900:1800','0900:1800','0900:1800','0900:1800','0000:0000','ACTIVE'),
(11,'0000:0000','0900:1800','0900:1800','0900:1800','0900:1800','0900:1800','0000:0000','ACTIVE'),
(12,'0000:0000','0900:1800','0900:1800','0900:1800','0900:1800','0900:1800','0000:0000','ACTIVE'),
(12,'0000:0000','0900:1800','0900:1800','0900:1800','0900:1800','0900:1800','0000:0000','ACTIVE'),
(12,'0000:0000','0900:1800','0900:1800','0900:1800','0900:1800','0900:1800','0000:0000','ACTIVE'),
(13,'0000:0000','0900:1800','0900:1800','0900:1800','0900:1800','0900:1800','0000:0000','ACTIVE'),
(13,'0000:0000','0900:1800','0900:1800','0900:1800','0900:1800','0900:1800','0000:0000','ACTIVE'),
(13,'0000:0000','0900:1800','0900:1800','0900:1800','0900:1800','0900:1800','0000:0000','ACTIVE'),
(14,'0000:0000','0900:1800','0900:1800','0900:1800','0900:1800','0900:1800','0000:0000','ACTIVE'),
(14,'0000:0000','0900:1800','0900:1800','0900:1800','0900:1800','0900:1800','0000:0000','ACTIVE'),
(14,'0000:0000','0900:1800','0900:1800','0900:1800','0900:1800','0900:1800','0000:0000','ACTIVE');
INSERT INTO contacts (address_id, telephone, cellphone, personal_id_number, business_id_number) VALUES
(7,'4453-6789','15-6894-4567','27093141', null);
INSERT INTO customers (contact_id, customer_name, email, password,customer_dob ,customer_state) VALUES
(1,'Agustin Larrarte','alarrarte@mail.com','1234abcd','19821112','ACTIVE');
/*
* appointment_time is stored as an unsigned int /YYMMDDHHMM
* for example: 1703021600 would be 16:00 02/02/2017
*/
INSERT INTO appointments (personal_schedule_id, customer_id, appointment_time, appointment_state)
VALUES (1,1,'1703021600', 'CONFIRMEND'),(1,1,'1703030900', 'CONFIRMEND'),(1,1,'1703041600', 'CONFIRMEND'),(1,1,'1703060900', 'CONFIRMEND');
|
-- MySQL dump 10.13 Distrib 8.0.15, for Win64 (x86_64)
--
-- Host: localhost Database: bedroom
-- ------------------------------------------------------
-- Server version 8.0.15
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
SET NAMES utf8 ;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `college_manager`
--
DROP TABLE IF EXISTS `college_manager`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
SET character_set_client = utf8mb4 ;
CREATE TABLE `college_manager` (
`college_id` int(11) NOT NULL COMMENT '学院id',
`counselor_account` varchar(11) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '辅导员id',
`grade_level` varchar(4) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '哪一届',
`permission_level` char(1) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '0' COMMENT '权限级别(默认为''0'',表示辅导员)',
PRIMARY KEY (`college_id`,`counselor_account`) USING BTREE,
KEY `counselor_account` (`counselor_account`) USING BTREE,
CONSTRAINT `college_manager_ibfk_1` FOREIGN KEY (`college_id`) REFERENCES `college` (`college_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT `college_manager_ibfk_2` FOREIGN KEY (`counselor_account`) REFERENCES `user` (`user_account`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='学院管理表';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `college_manager`
--
LOCK TABLES `college_manager` WRITE;
/*!40000 ALTER TABLE `college_manager` DISABLE KEYS */;
/*!40000 ALTER TABLE `college_manager` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2019-05-26 22:56:05
|
-- phpMyAdmin SQL Dump
-- version 4.4.8
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Apr 16, 2016 at 01:58 PM
-- Server version: 5.6.28-0ubuntu0.15.10.1
-- PHP Version: 5.6.11-1ubuntu3.1
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: `stumble-legal`
--
-- --------------------------------------------------------
--
-- Table structure for table `admins`
--
CREATE TABLE IF NOT EXISTS `admins` (
`id` bigint(11) unsigned NOT NULL,
`username` char(50) NOT NULL DEFAULT '',
`password` char(50) NOT NULL DEFAULT ''
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `admins`
--
INSERT INTO `admins` (`id`, `username`, `password`) VALUES
(1, 'stumble', '2fbd4ee396cdac223059952a7fe01e54');
-- --------------------------------------------------------
--
-- Table structure for table `associates`
--
CREATE TABLE IF NOT EXISTS `associates` (
`id` bigint(11) unsigned NOT NULL,
`username` char(50) NOT NULL DEFAULT '',
`password` char(50) NOT NULL DEFAULT '',
`fullname` char(50) NOT NULL DEFAULT '',
`email` char(50) NOT NULL DEFAULT '',
`phone` char(50) NOT NULL DEFAULT '',
`photo` char(255) DEFAULT '',
`law_firm` char(255) NOT NULL DEFAULT '',
`position` char(50) NOT NULL DEFAULT '',
`city` char(50) NOT NULL DEFAULT '',
`law_society_ref_number` char(50) NOT NULL DEFAULT '',
`association_number` char(50) NOT NULL DEFAULT '',
`is_private` tinyint(11) NOT NULL DEFAULT '0',
`status` tinyint(11) NOT NULL DEFAULT '1',
`alert_settings` int(11) NOT NULL DEFAULT '5',
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`insert_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB AUTO_INCREMENT=36 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `associates`
--
INSERT INTO `associates` (`id`, `username`, `password`, `fullname`, `email`, `phone`, `photo`, `law_firm`, `position`, `city`, `law_society_ref_number`, `association_number`, `is_private`, `status`, `alert_settings`, `updated_at`, `insert_time`) VALUES
(1, 'adam', 'adam', 'Adam Warlock', 'adam@stumble.com', '1234567', 'adam', 'AW Associates', 'CEO', 'Sydney', '', '', 0, 1, 5, '2016-04-15 14:55:44', '2015-06-26 08:59:19'),
(2, 'bruce', 'bruce', 'Bruce Wayne', '', '2345678', 'bruce', 'Wayne Associates', 'CTO', 'New South Wales', '', '', 0, 1, 5, '2016-04-15 14:55:44', '2015-06-26 09:00:10'),
(3, 'clark', 'clark', 'Clark Kent', 'clark@stumble.com', '', 'http://stumble.loc/photo/file/phpZ83lkB_20150710003931.jpg', 'Kent Law Firm', 'COO', 'Adelaide', '', '', 0, 1, 5, '2016-04-15 14:55:44', '2015-06-26 09:00:32'),
(4, 'daenerys', 'daenerys', 'Daenerys Stormborn', 'daenerys@stumble.com', '4567890', 'daenerys', 'Targeryan Associates', 'CFO', 'Queensland', '', '', 0, 1, 5, '2016-04-15 14:55:44', '2015-06-26 09:01:18'),
(5, 'barry', 'barry', 'Barry Allen', 'barry@stumble.com', '', 'barry', 'Allen & West Associates', '', 'Melbourne', '', '', 0, 1, 5, '2016-04-15 14:55:44', '2015-06-29 12:34:47'),
(6, 'charles', 'charles', 'Charles Xavier', 'charles@stumble.com', '6789012', 'charles', 'Xavier Law Firm', 'LTO', 'Brisbane', '', '', 0, 1, 5, '2016-04-15 14:55:44', '2015-06-29 12:36:56'),
(8, 'tapai', 'tori', 'Philip Agbada', 'philip@realv360.com', '123-4567', 'http://stumble.fullonapps.com/photo/file/phpmziRTd_20150730165534.jpg', 'Agbada and Associates', 'Senior Associate', 'Melbourne', '', '', 0, 1, 5, '2016-04-15 14:55:44', '2015-07-08 11:32:54'),
(9, 'Chayana', 'bratfeatures', 'Chayana Miers', 'chayana@mierslegal.com.au', '0424296663', 'http://stumble.fullonapps.com/photo/device/device_name/file/phpK41cDN_20160120051014.jpg', 'Miers Legal', 'Principal', 'Sydney', '55583', '', 0, 1, 5, '2016-04-15 14:55:44', '2015-07-21 03:01:42'),
(10, 'Adam Watt', 'Toughguy', 'Adam Watt', 'awpapc@gmail.com', '0404274918', '', 'PAPC', 'My Baby', 'Sydney', 'None', '22323', 0, 1, 5, '2016-04-15 14:55:44', '2015-07-21 14:04:09'),
(11, 'Noren Woo', 'chinita', 'Noren Woo', 'admin@mierslegal.com.au', '0475888610', 'http://stumble.fullonapps.com/photo/file/phpKWACE1_20150722035640.jpg', 'Miers Legal', 'Office Manager', 'Sydney', '', '', 0, 1, 5, '2016-04-15 14:55:44', '2015-07-21 19:55:41'),
(12, 'chetorres', 'm1dn1ght', 'Che Torres', 'cheryl@realv360.com', '+639278534828', 'http://stumble.fullonapps.com/photo/file/php3wriPE_20150727204954.jpg', '', '', 'Gold Coast', '', '', 0, 1, 5, '2016-04-15 14:55:44', '2015-07-27 20:49:55'),
(13, 'Cheryl', 'cheryl', 'Cheryl torres', 'che21_796@yahoo.com', '639278534828', 'http://stumble.fullonapps.com/photo/file/phpMfV57m_20150804060403.jpg', '', '', 'Katherine', '', '', 0, 1, 5, '2016-04-15 14:55:44', '2015-08-04 06:04:04'),
(14, 'Benjoben', 'Chairs', 'Joven Quinones', 'joven@kryptonitedigital.com', '09063006668', '', 'QL Law Firm', 'Attorney at Large', 'Adelaide', '1276', '1234', 0, 1, 5, '2016-04-15 14:55:44', '2015-08-04 06:35:48'),
(15, 'PAPC', 'Papc123', 'Adam Watt', 'adamwatt@me.com', '0404274918', 'http://stumble.fullonapps.com/photo/file/phpcCPqmQ_20150810100300.jpg', 'PAPC', 'Principle', 'Mackay', '', '', 1, 1, 5, '2016-04-15 14:55:44', '2015-08-10 08:48:03'),
(16, 'Alex', '1234', 'Alex Bracewell', 'agb@fullinapps.com', '+639175277801', '', 'ABC LAW', 'CEO', 'Brisbane', '45678', '1234567', 0, 1, 5, '2016-04-15 14:55:44', '2015-08-13 06:27:03'),
(17, 'Kryptstella', 'mystuff1990', 'Estella Lantot', 'stellakryptonite@gmail.com', '09435578868', '', '', '', 'Geelong', '', '', 0, 1, 5, '2016-04-15 14:55:44', '2015-08-17 07:29:40'),
(18, 'Jaspier', 'asakapa123', 'Jaspier Asensio', 'asakapa_6969@yahoo.com', '', '', '', '', 'Select City', '', '', 0, 1, 5, '2016-04-15 14:55:44', '2015-08-27 01:17:51'),
(19, 'delmarz', 'asakapa123', 'Delmas', 'asakapa_6969@yahoo.com', '', '', '', '', 'Armidale', '', '', 0, 1, 5, '2016-04-15 14:55:44', '2015-08-27 01:21:32'),
(20, 'zramled', 'boangka', 'zramled', 'zramled@asd.com', '', '', '', '', 'Bendigo', '', '', 0, 1, 5, '2016-04-15 14:55:44', '2015-09-07 05:43:04'),
(21, 'Bratfeatures', 'smartypants', 'Chayana Miers', 'chayana@mierslegal.com.au', '93563272', '', 'Miers Legal', 'Principal', 'Sydney', '55583', '55583', 0, 1, 5, '2016-04-15 14:55:44', '2015-12-01 06:01:20'),
(22, 'delmarz90', 'delmarz', 'Delmarz stamped', 'zramled@zramled.com', '51553', '', '', '', 'Select City', '', '', 0, 1, 5, '2016-04-15 14:55:44', '2015-12-10 06:29:32'),
(23, 'cheryltorres', 'm1dn1ght', 'Cheryl Torres', 'cheryl@kryptonitedigital.com', '+639278534828', 'http://stumble.fullonapps.com/photo/device/device_name/file/phpKpdxPD_20160119074550.jpg', '', '', 'Brisbane', '', '', 0, 1, 5, '2016-04-15 14:55:44', '2016-01-19 07:45:52'),
(24, 'Alexa', 'cigar555', 'Alex Bracewell', 'agb@fullonapps.com', '', 'http://stumble.fullonapps.com/photo/device/device_name/file/phpjE6lSQ_20160120081326.jpg', 'ABC', 'Staff', 'Sydney', '87654', '123456', 0, 1, 5, '2016-04-15 14:55:44', '2016-01-20 08:13:28'),
(25, 'Mitchie', 'asdfqwerty', 'Michelle D', 'dayangcomichelle0503@gmail.com', '091743892314', '', '', '', 'Albany', '', '', 0, 1, 5, '2016-04-15 14:55:44', '2016-01-21 11:24:48'),
(26, 'Test', 'Epicentre123', 'Adam', 'adamwatt@me.com', '0404274918', '', 'PAPC', 'Principle', 'Sydney', '', '', 0, 1, 5, '2016-04-15 14:55:44', '2016-01-27 23:34:31'),
(35, 'tapai', 'tori', 'Philip Tori Test', 'philip@realv360.com', '09075713256', 'test.jpg', '2', 'judge', 'new york', '1', '1', 0, 1, 5, '2016-04-15 20:06:58', '2016-04-15 15:05:31');
-- --------------------------------------------------------
--
-- Table structure for table `associate_devices`
--
CREATE TABLE IF NOT EXISTS `associate_devices` (
`id` bigint(11) unsigned NOT NULL,
`associate_id` bigint(20) unsigned NOT NULL,
`device` char(50) NOT NULL DEFAULT '',
`type` char(20) NOT NULL DEFAULT 'ios',
`token` char(255) NOT NULL DEFAULT '',
`insert_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB AUTO_INCREMENT=27 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `associate_devices`
--
INSERT INTO `associate_devices` (`id`, `associate_id`, `device`, `type`, `token`, `insert_time`) VALUES
(1, 8, 'iPhone7,1', 'ios', '92763d37306018c25d0d7bf6f90f15bac88a61ed02c187c8604989562187865c', '2015-07-27 20:02:25'),
(2, 12, 'iPhone5,2', 'ios', 'c636f0f5da9a00d0bbf4cdf315c2a0e4fdd24e60e530f6cb25bf4f1deb93b48c', '2015-07-28 06:02:21'),
(3, 12, 'iPhone5,2', 'ios', '331f0a867749eae8e4d650b4225782277344a84ab4ce206cab70aeffc56ac2ff', '2015-07-28 08:34:58'),
(4, 8, 'iPhone7,1', 'ios', '5ecd8438bc2f459e98db01dfdd1c58387f4c196397ae146818bcb440ebb073e5', '2015-07-28 10:03:32'),
(5, 2, 'iPhone7,1', 'ios', '5ecd8438bc2f459e98db01dfdd1c58387f4c196397ae146818bcb440ebb073e5', '2015-07-30 17:21:42'),
(6, 2, 'iPhone5,2', 'ios', 'c636f0f5da9a00d0bbf4cdf315c2a0e4fdd24e60e530f6cb25bf4f1deb93b48c', '2015-08-03 03:56:30'),
(7, 1, 'iPhone5,2', 'ios', 'c636f0f5da9a00d0bbf4cdf315c2a0e4fdd24e60e530f6cb25bf4f1deb93b48c', '2015-08-03 03:58:33'),
(8, 3, 'iPhone7,1', 'ios', '92763d37306018c25d0d7bf6f90f15bac88a61ed02c187c8604989562187865c', '2015-08-04 06:19:53'),
(9, 9, 'iPhone7,2', 'ios', '1eb93487ab84f850fdba74f5dc8c5525e1e108d066a3ee2c55fa34fbfaab81a8', '2015-08-04 08:58:20'),
(10, 8, 'iPhone7,2', 'ios', '97fcdda9a6aac06ef23d05fc16743b1c688bd699c36cbd2396c353446d18d527', '2015-08-04 11:02:20'),
(11, 14, 'iPhone4,1', 'ios', 'c85dad23a2b3677e54e041c77996a4d02855e2c13a22f8c6ea171384e1fe22a2', '2015-08-10 05:24:27'),
(12, 15, 'iPhone7,2', 'ios', '5679ae80edaa5d00cd22370a158a3296f5a7559d3420a49e6adac6fe01b76005', '2015-08-10 10:01:46'),
(13, 16, 'iPhone7,1', 'ios', '7b27807d99c0fcaced2e86b6005c5d67c73cb3f229f59ec17af1390fe1d2e409', '2015-08-14 08:05:27'),
(14, 17, 'iPhone4,1', 'ios', 'aa3d6725f9bb03b5ddb24b5831c3f1b0190ae6705139e91d629bb85399242e68', '2015-08-17 09:30:10'),
(15, 13, 'iPhone5,2', 'ios', 'c636f0f5da9a00d0bbf4cdf315c2a0e4fdd24e60e530f6cb25bf4f1deb93b48c', '2015-08-19 03:08:47'),
(16, 19, 'iPhone4,1', 'ios', 'aa3d6725f9bb03b5ddb24b5831c3f1b0190ae6705139e91d629bb85399242e68', '2015-08-27 01:31:36'),
(17, 13, 'iPhone5,2', 'ios', '331f0a867749eae8e4d650b4225782277344a84ab4ce206cab70aeffc56ac2ff', '2015-10-06 06:24:10'),
(18, 8, 'iPhone7,1', 'ios', '51ce61147ce5d05be9364f8dd68a850f61b01b9e317eb3e681589feeadd3883c', '2015-12-01 07:18:25'),
(19, 21, 'iPhone7,2', 'ios', '1eb93487ab84f850fdba74f5dc8c5525e1e108d066a3ee2c55fa34fbfaab81a8', '2015-12-02 21:55:06'),
(20, 22, 'iPhone7,2', 'ios', 'b16b07811a3b0c9eb14e8fc4d15d503492321cf4710707f578c328c26e5e9a0e', '2015-12-10 07:10:09'),
(21, 8, 'iPhone7,1', 'ios', 'e60a14557fb31486554924d59cf582826086051cd6aed0c94ab8f2d9cb1f4c8f', '2016-01-15 11:21:06'),
(22, 8, 'iPhone7,1', 'ios', '5d480533c05c38f0032c8502a6c30befb26cab9ff9e699260229ef63dc713735', '2016-01-18 14:19:04'),
(23, 9, 'iPhone7,2', 'ios', '9aa40222a89853260281440be70939ba1ba1b17b8caec14f37c28a90ba5c0a71', '2016-01-19 08:01:41'),
(24, 23, 'iPhone8,1', 'ios', '0f57034d621b1d7b3de0dc90c2aedef0ad8421fa7d0ce03530eb7337648606c2', '2016-01-22 03:38:27'),
(25, 24, 'iPhone8,2', 'ios', '41ae9527c3093d359a44b4f61efa4ac3685f76c366e430105ec6c2a55c7cf08d', '2016-01-24 05:37:18'),
(26, 26, 'iPhone7,2', 'ios', '7727829febc15625301c3ce4997ac17b2168a1d74c0733a230f44fc56d3ace93', '2016-01-28 07:15:22');
-- --------------------------------------------------------
--
-- Table structure for table `associate_location`
--
CREATE TABLE IF NOT EXISTS `associate_location` (
`id` bigint(11) unsigned NOT NULL,
`associate_id` bigint(11) unsigned NOT NULL,
`court_id` bigint(11) unsigned NOT NULL,
`date_time` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`distance` float NOT NULL DEFAULT '0',
`insert_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB AUTO_INCREMENT=66 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `associate_location`
--
INSERT INTO `associate_location` (`id`, `associate_id`, `court_id`, `date_time`, `distance`, `insert_time`) VALUES
(1, 12, 174, '2015-08-18 04:37:04', 0.0255901, '2015-07-27 20:50:27'),
(3, 2, 174, '2015-08-03 20:34:47', 0.884516, '2015-08-03 03:57:03'),
(4, 1, 42, '2015-10-06 10:30:40', 0, '2015-08-03 03:59:05'),
(6, 3, 174, '2015-08-15 10:40:57', 0.012183, '2015-08-04 06:20:24'),
(8, 15, 42, '2015-08-10 10:04:18', 0.593858, '2015-08-10 08:48:36'),
(9, 16, 174, '2015-08-13 09:31:16', 0.579591, '2015-08-13 06:27:35'),
(27, 21, 156, '2015-12-23 07:06:15', 0.348755, '2015-12-01 07:46:45'),
(28, 21, 169, '2015-12-23 07:06:15', 0.348755, '2015-12-01 07:46:45'),
(29, 21, 42, '2015-12-23 07:06:15', 0.348755, '2015-12-01 07:46:45'),
(30, 21, 167, '2015-12-23 07:06:15', 0.348755, '2015-12-01 07:46:45'),
(31, 21, 172, '2015-12-23 07:06:15', 0.506194, '2015-12-01 07:46:45'),
(32, 21, 29, '2015-12-23 07:06:15', 0.507811, '2015-12-01 07:46:45'),
(33, 21, 170, '2015-12-23 07:06:15', 0.57545, '2015-12-01 07:46:45'),
(44, 13, 174, '2015-12-18 07:51:46', 0.020877, '2015-12-18 07:51:19'),
(45, 21, 158, '2015-12-23 07:06:15', 0.757878, '2015-12-23 07:05:20'),
(46, 9, 42, '2016-01-28 18:32:17', 0.363691, '2016-01-19 08:01:48'),
(47, 9, 167, '2016-01-28 18:32:17', 0.363691, '2016-01-19 08:01:48'),
(48, 9, 156, '2016-01-28 18:32:17', 0.363691, '2016-01-19 08:01:48'),
(49, 9, 169, '2016-01-28 18:32:17', 0.363691, '2016-01-19 08:01:48'),
(50, 9, 172, '2016-01-28 18:32:17', 0.517368, '2016-01-19 08:01:48'),
(63, 9, 29, '2016-01-28 18:32:17', 0.527128, '2016-01-28 18:31:52'),
(64, 9, 170, '2016-01-28 18:32:17', 0.596393, '2016-01-28 18:31:52'),
(65, 9, 158, '2016-01-28 18:32:17', 0.768076, '2016-01-28 18:31:52');
-- --------------------------------------------------------
--
-- Table structure for table `auth`
--
CREATE TABLE IF NOT EXISTS `auth` (
`id` bigint(11) unsigned NOT NULL,
`key` char(64) NOT NULL DEFAULT '',
`secret` char(64) NOT NULL DEFAULT '',
`type` char(10) NOT NULL DEFAULT '',
`version` float unsigned NOT NULL DEFAULT '1'
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `auth`
--
INSERT INTO `auth` (`id`, `key`, `secret`, `type`, `version`) VALUES
(1, '8EF86366AE6E69542FD587FD627F2', 'D2444A6FF899B9D42C88255442B6B', 'ios', 1),
(2, '2867a14229ab3af583e75511f99f9735', 'e84e30b9390cdb64db6db2c9ab87846d', 'android', 1);
-- --------------------------------------------------------
--
-- Table structure for table `courts`
--
CREATE TABLE IF NOT EXISTS `courts` (
`id` bigint(11) unsigned NOT NULL,
`name` char(50) NOT NULL DEFAULT '',
`address` char(255) NOT NULL DEFAULT '',
`latitude` double DEFAULT NULL,
`longitude` double DEFAULT NULL,
`insert_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB AUTO_INCREMENT=175 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `courts`
--
INSERT INTO `courts` (`id`, `name`, `address`, `latitude`, `longitude`, `insert_time`) VALUES
(1, 'Albion Park', '96 Tongarra Rd', -34.569774, 150.778951, '2015-06-22 15:39:02'),
(2, 'Albury', '515 Olive St', -36.080162048339844, 146.91787719726562, '2015-06-22 15:39:02'),
(3, 'Armidale', '5 Moore St', -30.512615203857422, 151.6656494140625, '2015-06-22 15:39:02'),
(4, 'Ballina', 'River St', -28.86896324157715, 153.5565948486328, '2015-06-22 15:39:02'),
(5, 'Balmain', '368 Darling St', -33.85661315917969, 151.1773223876953, '2015-06-22 15:39:02'),
(6, 'Balranald', 'Council Chambers 70 Market St', -34.64164352416992, 143.56539916992188, '2015-06-22 15:39:02'),
(7, 'Bankstown', 'Cnr Chapel Road & The Mall', -33.917232513427734, 151.03292846679688, '2015-06-22 15:39:02'),
(8, 'Batemans Bay', '24 Orient St', -35.70766067504883, 150.17745971679688, '2015-06-22 15:39:02'),
(9, 'Bathurst', 'Russell St', -33.419105529785156, 149.57997131347656, '2015-06-22 15:39:02'),
(10, 'Bega', 'Cnr Gipps & Carp St', -36.67427444458008, 149.84326171875, '2015-06-22 15:39:02'),
(11, 'Bellingen', '48 Hyde St', -30.452739715576172, 152.8975830078125, '2015-06-22 15:39:02'),
(12, 'Belmont', '530 Pacific Highway', -33.03477478027344, 151.66061401367188, '2015-06-22 15:39:02'),
(13, 'Bidura Children''s', '357 Glebe Point Rd?Glebe', -33.87611770629883, 151.18515014648438, '2015-06-22 15:39:02'),
(14, 'Blacktown', '1 Kildare Rd', -33.76885986328125, 150.9058837890625, '2015-06-22 15:39:02'),
(15, 'Blayney', 'Adelaide St', -33.532466888427734, 149.2552490234375, '2015-06-22 15:39:02'),
(16, 'Boggabilla', 'Merriwa St', -28.602680206298828, 150.3600311279297, '2015-06-22 15:39:02'),
(17, 'Bombala', 'High St', -36.90706253051758, 149.2379608154297, '2015-06-22 15:39:02'),
(18, 'Bourke', '55-57 Oxley St', -30.08967399597168, 145.93724060058594, '2015-06-22 15:39:02'),
(19, 'Braidwood', 'C/- Court house Queanbeyan', -35.35490036010742, 149.23121643066406, '2015-06-22 15:39:02'),
(20, 'Brewarrina', 'Bathurst St', -29.961416244506836, 146.8588104248047, '2015-06-22 15:39:02'),
(21, 'Broadmeadow Children''s', '19-23 Lambton Road?Broadmeadow', -32.92494583129883, 151.7349853515625, '2015-06-22 15:39:02'),
(22, 'Broken Hill', 'Argent St', -31.954984664916992, 141.4710235595703, '2015-06-22 15:39:02'),
(23, 'Burwood', '7-9 Belmore St', -33.87909698486328, 151.10476684570312, '2015-06-22 15:39:02'),
(24, 'Byron Bay', 'Middleton St', -28.645429611206055, 153.61460876464844, '2015-06-22 15:39:02'),
(25, 'Camden', 'John Street', -34.0535888671875, 150.69522094726562, '2015-06-22 15:39:02'),
(26, 'Campbelltown', 'Railway St', -34.06486129760742, 150.8150177001953, '2015-06-22 15:39:02'),
(27, 'Campbelltown Children''s', 'Queen St', -34.06456756591797, 150.816162109375, '2015-06-22 15:39:02'),
(28, 'Casino', 'Walker Street', -28.867895126342773, 153.0473175048828, '2015-06-22 15:39:02'),
(29, 'Central (criminal cases ONLY)', '98 Liverpool St?Sydney', -33.875972747802734, 151.20706176757812, '2015-06-22 15:39:02'),
(30, 'Cessnock', 'Maitland Rd', -32.8286247253418, 151.37872314453125, '2015-06-22 15:39:02'),
(31, 'Cobar', '31 Barton St', -31.498916625976562, 145.8362274169922, '2015-06-22 15:39:02'),
(32, 'Coffs Harbour', '20 Moonee St', -30.297203063964844, 153.11207580566406, '2015-06-22 15:39:02'),
(33, 'Condobolin', 'Bathurst St', -33.08777618408203, 147.14418029785156, '2015-06-22 15:39:02'),
(34, 'Cooma', 'Vale St', -36.23746871948242, 149.12620544433594, '2015-06-22 15:39:02'),
(35, 'Coonabarabran', 'Cnr John & Delgarno Sts', -31.27391242980957, 149.2774200439453, '2015-06-22 15:39:02'),
(36, 'Coonamble', '27 Aberford St', -30.95450782775879, 148.38995361328125, '2015-06-22 15:39:02'),
(37, 'Cootamundra', '298 Parker St', -34.63888168334961, 148.02383422851562, '2015-06-22 15:39:02'),
(38, 'Corowa', 'Cnr Church & Queen Sts', -35.99797821044922, 146.39002990722656, '2015-06-22 15:39:02'),
(39, 'Cowra', 'Cnr Kendal & Brisbane Sts', -33.83470916748047, 148.69122314453125, '2015-06-22 15:39:02'),
(40, 'Crookwell', 'Goulburn St', -34.47145462036133, 149.49032592773438, '2015-06-22 15:39:02'),
(41, 'Deniliquin', 'Cnr Poictier & Wellington Sts', -35.533538818359375, 144.96356201171875, '2015-06-22 15:39:02'),
(42, 'Downing Centre Level 5 (civil claims cases ONLY)', '143-147 Liverpool Street', -33.87710952758789, 151.20912170410156, '2015-06-22 15:39:02'),
(43, 'Drug Court', 'Parramatta Court House?12 George Street?Parramatta', -33.81300354003906, 151.00267028808594, '2015-06-22 15:39:02'),
(44, 'Dubbo', 'Brisbane St', -32.244659423828125, 148.60430908203125, '2015-06-22 15:39:02'),
(45, 'Dunedoo', '24 Dilgah St', -32.015968322753906, 149.3882598876953, '2015-06-22 15:39:02'),
(46, 'Dungog', 'Lord St', -32.405548095703125, 151.75430297851562, '2015-06-22 15:39:02'),
(47, 'East Maitland', 'John St', -32.7459716796875, 151.58963012695312, '2015-06-22 15:39:02'),
(48, 'Eden', 'Imlay St', -37.05332946777344, 149.90301513671875, '2015-06-22 15:39:02'),
(49, 'Fairfield', 'Cnr Spencer St & Court Rd', -33.870079040527344, 150.95773315429688, '2015-06-22 15:39:02'),
(50, 'Finley', 'Cnr Denison & Headford Sts', -35.64297866821289, 145.57521057128906, '2015-06-22 15:39:02'),
(51, 'Forbes', 'Victoria Lane', -33.3869514465332, 148.00894165039062, '2015-06-22 15:39:02'),
(52, 'Forster', 'Lake St', -32.18336486816406, 152.5210418701172, '2015-06-22 15:39:02'),
(53, 'Gilgandra', '10 Myrtle St', -31.71004867553711, 148.667236328125, '2015-06-22 15:39:02'),
(54, 'Glen Innes', 'Grey St', -29.738758087158203, 151.7355499267578, '2015-06-22 15:39:02'),
(55, 'Gloucester', 'Church St', -32.01432418823242, 151.95748901367188, '2015-06-22 15:39:02'),
(56, 'Gosford', 'Donnison St & Henry Parry Drive', -33.42728042602539, 151.34425354003906, '2015-06-22 15:39:02'),
(57, 'Goulburn', 'Montague St', -34.75341796875, 149.71629333496094, '2015-06-22 15:39:02'),
(58, 'Grafton', '47 Victoria St', -29.692684173583984, 152.93321228027344, '2015-06-22 15:39:02'),
(59, 'Grenfell', 'Camp St', -33.894737243652344, 148.1593780517578, '2015-06-22 15:39:02'),
(60, 'Griffith', 'Banna Avenue', -34.28864288330078, 146.05075073242188, '2015-06-22 15:39:02'),
(61, 'Gulgong', 'Herbert St', -32.362361907958984, 149.53359985351562, '2015-06-22 15:39:02'),
(62, 'Gundagai', '161-169 Sheridan St', -35.06448745727539, 148.10501098632812, '2015-06-22 15:39:02'),
(63, 'Gunnedah', 'Conadilly St', -30.974201202392578, 150.2457733154297, '2015-06-22 15:39:02'),
(64, 'Hay', 'Cnr Moppett & Pine Sts', -34.50845718383789, 144.8411102294922, '2015-06-22 15:39:02'),
(65, 'Hillston', 'Cnr Molesworth & McGee Streets', -33.486480712890625, 145.53224182128906, '2015-06-22 15:39:02'),
(66, 'Holbrook', 'Albury St', -35.72318649291992, 147.31431579589844, '2015-06-22 15:39:02'),
(67, 'Hornsby', '294 Pacific Highway', -33.70098114013672, 151.0973358154297, '2015-06-22 15:39:02'),
(68, 'Inverell', 'Otho Street', -29.776275634765625, 151.1134490966797, '2015-06-22 15:39:02'),
(69, 'Junee', 'Belmore Street', -34.87188720703125, 147.5870819091797, '2015-06-22 15:39:02'),
(70, 'Katoomba', '5-7 Civic Place', -33.710731506347656, 150.31387329101562, '2015-06-22 15:39:02'),
(71, 'Kempsey', '2 Sea Street West Kempsey', -31.078826904296875, 152.83151245117188, '2015-06-22 15:39:02'),
(72, 'Kiama', '34-36 Terralong Street', -34.66755294799805, 150.85012817382812, '2015-06-22 15:39:02'),
(73, 'Kogarah', '17 Montgomery Street', -33.96400833129883, 151.1338348388672, '2015-06-22 15:39:02'),
(74, 'Kurri Kurri', 'Cnr Victoria & Lang Streets', -32.818790435791016, 151.48060607910156, '2015-06-22 15:39:02'),
(75, 'Kyogle', 'Geneva Street', -28.620058059692383, 153.00511169433594, '2015-06-22 15:39:02'),
(76, 'Lake Cargelligo', '51 Canada Street', -33.29961395263672, 146.3745880126953, '2015-06-22 15:39:02'),
(77, 'Leeton', 'Church Street', -34.55445098876953, 146.40443420410156, '2015-06-22 15:39:02'),
(78, 'Lightning Ridge', 'Cnr Opal & Morilla Street', -29.42778968811035, 147.9789581298828, '2015-06-22 15:39:02'),
(79, 'Lismore', '9-11 Zadoc Street', -28.80539321899414, 153.27951049804688, '2015-06-22 15:39:02'),
(80, 'Lithgow', 'Cnr Bridge & Mort Streets', -33.48104476928711, 150.16136169433594, '2015-06-22 15:39:02'),
(81, 'Liverpool', '150 George St', -33.9205207824707, 150.92515563964844, '2015-06-22 15:39:02'),
(82, 'Lockhart', 'Cnr Mathews & Hebden Streets', -35.22229766845703, 146.71603393554688, '2015-06-22 15:39:02'),
(83, 'Macksville', 'River Street', -30.707340240478516, 152.9253387451172, '2015-06-22 15:39:02'),
(84, 'Maclean', 'Macnaughton Place', -29.45789337158203, 153.1963348388672, '2015-06-22 15:39:02'),
(85, 'Maitland', 'High Street', -32.73489761352539, 151.55873107910156, '2015-06-22 15:39:02'),
(86, 'Manilla', 'Cnr Court and Manilla Streets', -30.74968719482422, 150.72119140625, '2015-06-22 15:39:02'),
(87, 'Manly', '2 Belgrave Street', -33.79840850830078, 151.2847137451172, '2015-06-22 15:39:02'),
(88, 'Milton', 'Princes Highway', -35.317787170410156, 150.4402313232422, '2015-06-22 15:39:02'),
(89, 'Moama', 'Cnr Francis and Maiden Streets', -36.10997009277344, 144.75816345214844, '2015-06-22 15:39:02'),
(90, 'Moree', 'Frome Street', -29.480623245239258, 149.84483337402344, '2015-06-22 15:39:02'),
(91, 'Moruya', 'Vulcan Street', -35.90907287597656, 150.08106994628906, '2015-06-22 15:39:02'),
(92, 'Moss Vale', 'Argyle Street', -34.5405387878418, 150.38706970214844, '2015-06-22 15:39:02'),
(93, 'Moulamein', 'Tallow Street', -35.08881759643555, 144.03457641601562, '2015-06-22 15:39:02'),
(94, 'Mt Druitt', '59 North Parade', -33.7691535949707, 150.822509765625, '2015-06-22 15:39:02'),
(95, 'Mudgee', '96 Market Street', -32.58964157104492, 149.5823974609375, '2015-06-22 15:39:02'),
(96, 'Mullumbimby', 'Dalley Street', -28.55217742919922, 153.4998016357422, '2015-06-22 15:39:02'),
(97, 'Mungindi', '146 St George Street', -28.977420806884766, 148.9903106689453, '2015-06-22 15:39:02'),
(98, 'Murrurundi', 'Murulla Street', -31.763996124267578, 150.82980346679688, '2015-06-22 15:39:02'),
(99, 'Murwillumbah', '61 Main Street', -28.326396942138672, 153.39515686035156, '2015-06-22 15:39:02'),
(100, 'Muswellbrook', 'Bridge Street', -32.25985336303711, 150.8894805908203, '2015-06-22 15:39:02'),
(101, 'Narooma', 'Princess Highway', -36.21602249145508, 150.13018798828125, '2015-06-22 15:39:02'),
(102, 'Narrabri', '56 Maitland Street', -30.328819274902344, 149.7855682373047, '2015-06-22 15:39:02'),
(103, 'Narrandera', 'Cnr Cadell & Larmer Streets', -34.749107360839844, 146.55014038085938, '2015-06-22 15:39:02'),
(104, 'Narromine', '47 Merilba Street', -32.233070373535156, 148.24148559570312, '2015-06-22 15:39:02'),
(105, 'Newcastle', 'Cnr Church & Bolton Streets', -32.929927825927734, 151.78237915039062, '2015-06-22 15:39:02'),
(106, 'Newtown', '220 Australia Street', -33.89702224731445, 151.17855834960938, '2015-06-22 15:39:02'),
(107, 'North Sydney', '94 Pacific Highway', -33.8383674621582, 151.20632934570312, '2015-06-22 15:39:02'),
(108, 'Nowra', 'Plunkett Street', -34.87880325317383, 150.6018829345703, '2015-06-22 15:39:02'),
(109, 'Nyngan', '77 Cobar Street', -31.563438415527344, 147.1941375732422, '2015-06-22 15:39:02'),
(110, 'Oberon', 'Queen Street', -33.706451416015625, 149.86215209960938, '2015-06-22 15:39:02'),
(111, 'Orange', 'Cnr Lords Place & Byng Street', -33.28171157836914, 149.10133361816406, '2015-06-22 15:39:02'),
(112, 'Parkes', '37 Currajong Street', -33.1268424987793, 148.1746826171875, '2015-06-22 15:39:02'),
(113, 'Parramatta', '12 George Street', -33.81300354003906, 151.00267028808594, '2015-06-22 15:39:02'),
(114, 'Parramatta Children''s', '2 George Street', -33.8125, 151.00091552734375, '2015-06-22 15:39:02'),
(115, 'Peak Hill', 'Derribong Street', -32.72590637207031, 148.1898193359375, '2015-06-22 15:39:02'),
(116, 'Penrith', '62-74 Henry Street', -33.7533073425293, 150.70098876953125, '2015-06-22 15:39:02'),
(117, 'Picton', '88 Argyle Street', -34.168392181396484, 150.61248779296875, '2015-06-22 15:39:02'),
(118, 'Port Kembla', 'Darcy Road', -34.47950744628906, 150.90573120117188, '2015-06-22 15:39:02'),
(119, 'Port Macquarie', '22-26 Murray Street', -31.43011474609375, 152.9110107421875, '2015-06-22 15:39:02'),
(120, 'Queanbeyan', '2 Farrer Place', -35.35438537597656, 149.2313995361328, '2015-06-22 15:39:02'),
(121, 'Quirindi', 'George Street', -31.5092716217041, 150.67977905273438, '2015-06-22 15:39:02'),
(122, 'Raymond Terrace', 'William Street', -32.76286697387695, 151.7440948486328, '2015-06-22 15:39:02'),
(123, 'Richmond', '288 Windsor Street', -33.59694290161133, 150.7504425048828, '2015-06-22 15:39:02'),
(124, 'Ryde', '814 Victoria Road', -33.81548309326172, 151.0995635986328, '2015-06-22 15:39:02'),
(125, 'Rylstone', 'Louee Street', -32.79997253417969, 149.97064208984375, '2015-06-22 15:39:02'),
(126, 'Scone', 'Cnr Liverpool and Main Streets', -32.05089569091797, 150.86868286132812, '2015-06-22 15:39:02'),
(127, 'Singleton', 'Elizabeth Street', -32.56277847290039, 151.1728515625, '2015-06-22 15:39:02'),
(128, 'State Coroner''s', '44-46 Parramatta Road', -33.885154724121094, 151.1836700439453, '2015-06-22 15:39:02'),
(129, 'Sutherland', 'Cnr Flora & Belmont Streets', -34.03231430053711, 151.06143188476562, '2015-06-22 15:39:02'),
(130, 'Tamworth', 'Cnr Marius and Fitzroy Streets', -31.090110778808594, 150.93310546875, '2015-06-22 15:39:02'),
(131, 'Taree', '85 Albert Street', -31.91336441040039, 152.45689392089844, '2015-06-22 15:39:02'),
(132, 'Temora', '154 De Boos Street', -34.447731018066406, 147.53565979003906, '2015-06-22 15:39:02'),
(133, 'Tenterfield', '94 Molesworth Street', -29.05017852783203, 152.01803588867188, '2015-06-22 15:39:02'),
(134, 'Toronto', '140-142 Carey Street', -33.01251220703125, 151.5938720703125, '2015-06-22 15:39:02'),
(135, 'Tumbarumba', 'Bridge Street', -35.777462005615234, 148.01280212402344, '2015-06-22 15:39:02'),
(136, 'Tumut', 'Cnr Wynyard and Fitzroy Streets', -35.30062484741211, 148.22494506835938, '2015-06-22 15:39:02'),
(137, 'Tweed Heads', '50-52 Recreation Street', -28.179973602294922, 153.53909301757812, '2015-06-22 15:39:02'),
(138, 'Wagga Wagga', '49 Fitzmaurice Street', -35.10682678222656, 147.37025451660156, '2015-06-22 15:39:02'),
(139, 'Walcha', 'Apsley Street', -30.982831954956055, 151.5913848876953, '2015-06-22 15:39:02'),
(140, 'Walgett', 'Wee Waa Street', -30.022064208984375, 148.11744689941406, '2015-06-22 15:39:02'),
(141, 'Warialda', 'Stephen Street', -29.537668228149414, 150.57565307617188, '2015-06-22 15:39:02'),
(142, 'Warren', '174 Dubbo Street', -31.701805114746094, 147.8382568359375, '2015-06-22 15:39:02'),
(143, 'Wauchope', '41 Hastings Street', -31.45586585998535, 152.73202514648438, '2015-06-22 15:39:02'),
(144, 'Waverley', '151 Bronte Road', -33.897926330566406, 151.2520294189453, '2015-06-22 15:39:02'),
(145, 'Wee Waa', 'Cnr Rose and Nelson Streets', -30.223888397216797, 149.44651794433594, '2015-06-22 15:39:02'),
(146, 'Wellington', 'Cnr Maughan and Arthur Streets', -32.55607604980469, 148.94407653808594, '2015-06-22 15:39:02'),
(147, 'Wentworth', 'Darling Street', -34.101783752441406, 141.91783142089844, '2015-06-22 15:39:02'),
(148, 'West Wyalong', 'Court Street', -33.92478561401367, 147.20362854003906, '2015-06-22 15:39:02'),
(149, 'Wilcannia', 'Reid Street', -31.56083106994629, 143.37586975097656, '2015-06-22 15:39:02'),
(150, 'Windsor', 'Cnr North and Courts Streets', -33.60502624511719, 150.826171875, '2015-06-22 15:39:02'),
(151, 'Wollongong', 'Market and Church Streets', -34.423744201660156, 150.89581298828125, '2015-06-22 15:39:02'),
(152, 'Woy Woy', '78-80 Blackwall Road', -33.48744583129883, 151.32603454589844, '2015-06-22 15:39:02'),
(153, 'Wyong', 'Cnr Hely and Anzac Streets', -33.28168869018555, 151.42437744140625, '2015-06-22 15:39:02'),
(154, 'Yass', 'Cnr Rossi & Comur Streets', -34.84047317504883, 148.90919494628906, '2015-06-22 15:39:02'),
(155, 'Young', '68-70 Lynch Street', -34.31218338012695, 148.29815673828125, '2015-06-22 15:39:02'),
(156, 'Sydney District Court', '143-147 Liverpool Street', -33.87710952758789, 151.20912170410156, '2015-06-22 15:39:02'),
(157, 'Quenbeyan', '2 Farrer Place', -35.35438537597656, 149.2313995361328, '2015-06-22 15:39:02'),
(158, 'Supreme Court of NSW', 'Level 7-13 Law Courts Building 184 Phillip Street', -33.86903762817383, 151.21156311035156, '2015-06-22 15:39:02'),
(159, 'Children - Bidura', '357 Glebe Point Road', -33.8761100769043, 151.18515014648438, '2015-06-22 15:39:02'),
(160, 'Children - Broadmeadow', '19-23 Lambton Road', -32.92494583129883, 151.7349853515625, '2015-06-22 15:39:02'),
(161, 'Children - Campbelltown', 'Queen Street', -34.06455993652344, 150.816162109375, '2015-06-22 15:39:02'),
(162, 'Children – Port Kembla', 'Darcy Road', -34.47949981689453, 150.90573120117188, '2015-06-22 15:39:02'),
(163, 'Children - Parramatta', '2 George Street', -33.8125, 151.00091552734375, '2015-06-22 15:39:02'),
(164, 'Children – Woy Woy', 'Blackwell Road', -33.49296188354492, 151.3275146484375, '2015-06-22 15:39:02'),
(165, 'Children - Wyong', 'corner Hely Street and Anzac Avenue', -33.281436920166016, 151.4226837158203, '2015-06-22 15:39:02'),
(166, 'Drug Court of NSW (Parramatta)', 'Parramatta Court House Ground Floor?12 George Street?Parramatta New South Wales 2150', -33.81300354003906, 151.00267028808594, '2015-06-22 15:39:02'),
(167, 'Drug Court of NSW (Sydney)', 'Downing Centre Court Complex?Lower Ground Floor?143 - 147 Liverpool Street?Sydney NSW 2000', -33.87710952758789, 151.20912170410156, '2015-06-22 15:39:02'),
(168, 'Drug Court of NSW (Hunter)', 'Toronto Court House?140 - 142 Carey Street?Toronto NSW 2283?', -33.01251220703125, 151.5938720703125, '2015-06-22 15:39:02'),
(169, 'Downing Centre Level 4 (criminal and general cases', 'Level 4 Downing Centre 143-147 Liverpool Street', -33.87710952758789, 151.20912170410156, '2015-06-22 15:39:02'),
(170, 'The Land and Environment Court of NSW', 'Level 4 225 Macquarie Street?Windeyer Chambers?Sydney NSW 2000', -33.87364959716797, 151.20689392089844, '2015-06-22 15:39:02'),
(171, 'Family Court of Australia - Parramatta', '1/3 George St Parramatta NSW 2150', -33.81315994262695, 151.0010986328125, '2015-06-22 15:39:02'),
(172, 'Family Court of Australia - Sydney', '97-99 Goulburn St Sydney', -33.87858200073242, 151.2082061767578, '2015-06-22 15:39:02'),
(173, 'Wooloongong', 'Market and Church Streets', -34.423744201660156, 150.89581298828125, '2015-06-22 15:39:02'),
(174, 'ZebuCourt', 'PH', 10.312408, 124.00615, '2015-06-22 15:39:02');
-- --------------------------------------------------------
--
-- Table structure for table `court_details`
--
CREATE TABLE IF NOT EXISTS `court_details` (
`id` bigint(11) unsigned NOT NULL,
`court_id` bigint(11) unsigned NOT NULL,
`type` char(50) NOT NULL DEFAULT '',
`level` char(50) NOT NULL DEFAULT '',
`active` tinyint(11) NOT NULL DEFAULT '0'
) ENGINE=InnoDB AUTO_INCREMENT=400 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `court_details`
--
INSERT INTO `court_details` (`id`, `court_id`, `type`, `level`, `active`) VALUES
(1, 1, 'Civil', 'Local', 1),
(2, 2, 'Civil', 'Local', 1),
(3, 3, 'Civil', 'Local', 1),
(4, 4, 'Civil', 'Local', 1),
(5, 5, 'Civil', 'Local', 1),
(6, 6, 'Civil', 'Local', 1),
(7, 7, 'Civil', 'Local', 1),
(8, 8, 'Civil', 'Local', 1),
(9, 9, 'Civil', 'Local', 1),
(10, 10, 'Civil', 'Local', 1),
(11, 11, 'Civil', 'Local', 1),
(12, 12, 'Civil', 'Local', 1),
(13, 13, 'Civil', 'Local', 1),
(14, 14, 'Civil', 'Local', 1),
(15, 15, 'Civil', 'Local', 1),
(16, 16, 'Civil', 'Local', 1),
(17, 17, 'Civil', 'Local', 1),
(18, 18, 'Civil', 'Local', 1),
(19, 19, 'Civil', 'Local', 1),
(20, 20, 'Civil', 'Local', 1),
(21, 21, 'Civil', 'Local', 1),
(22, 22, 'Civil', 'Local', 1),
(23, 23, 'Civil', 'Local', 1),
(24, 24, 'Civil', 'Local', 1),
(25, 25, 'Civil', 'Local', 1),
(26, 26, 'Civil', 'Local', 1),
(27, 27, 'Civil', 'Local', 1),
(28, 28, 'Civil', 'Local', 1),
(29, 29, 'Civil', 'Local', 1),
(30, 30, 'Civil', 'Local', 1),
(31, 31, 'Civil', 'Local', 1),
(32, 32, 'Civil', 'Local', 1),
(33, 33, 'Civil', 'Local', 1),
(34, 34, 'Civil', 'Local', 1),
(35, 35, 'Civil', 'Local', 1),
(36, 36, 'Civil', 'Local', 1),
(37, 37, 'Civil', 'Local', 1),
(38, 38, 'Civil', 'Local', 1),
(39, 39, 'Civil', 'Local', 1),
(40, 40, 'Civil', 'Local', 1),
(41, 41, 'Civil', 'Local', 1),
(42, 42, 'Civil', 'Local', 1),
(43, 43, 'Civil', 'Local', 1),
(44, 44, 'Civil', 'Local', 1),
(45, 45, 'Civil', 'Local', 1),
(46, 46, 'Civil', 'Local', 1),
(47, 47, 'Civil', 'Local', 1),
(48, 48, 'Civil', 'Local', 1),
(49, 49, 'Civil', 'Local', 1),
(50, 50, 'Civil', 'Local', 1),
(51, 51, 'Civil', 'Local', 1),
(52, 52, 'Civil', 'Local', 1),
(53, 53, 'Civil', 'Local', 1),
(54, 54, 'Civil', 'Local', 1),
(55, 55, 'Civil', 'Local', 1),
(56, 56, 'Civil', 'Local', 1),
(57, 57, 'Civil', 'Local', 1),
(58, 58, 'Civil', 'Local', 1),
(59, 59, 'Civil', 'Local', 1),
(60, 60, 'Civil', 'Local', 1),
(61, 61, 'Civil', 'Local', 1),
(62, 62, 'Civil', 'Local', 1),
(63, 63, 'Civil', 'Local', 1),
(64, 64, 'Civil', 'Local', 1),
(65, 65, 'Civil', 'Local', 1),
(66, 66, 'Civil', 'Local', 1),
(67, 67, 'Civil', 'Local', 1),
(68, 68, 'Civil', 'Local', 1),
(69, 69, 'Civil', 'Local', 1),
(70, 70, 'Civil', 'Local', 1),
(71, 71, 'Civil', 'Local', 1),
(72, 72, 'Civil', 'Local', 1),
(73, 73, 'Civil', 'Local', 1),
(74, 74, 'Civil', 'Local', 1),
(75, 75, 'Civil', 'Local', 1),
(76, 76, 'Civil', 'Local', 1),
(77, 77, 'Civil', 'Local', 1),
(78, 78, 'Civil', 'Local', 1),
(79, 79, 'Civil', 'Local', 1),
(80, 80, 'Civil', 'Local', 1),
(81, 81, 'Civil', 'Local', 1),
(82, 82, 'Civil', 'Local', 1),
(83, 83, 'Civil', 'Local', 1),
(84, 84, 'Civil', 'Local', 1),
(85, 85, 'Civil', 'Local', 1),
(86, 86, 'Civil', 'Local', 1),
(87, 87, 'Civil', 'Local', 1),
(88, 88, 'Civil', 'Local', 1),
(89, 89, 'Civil', 'Local', 1),
(90, 90, 'Civil', 'Local', 1),
(91, 91, 'Civil', 'Local', 1),
(92, 92, 'Civil', 'Local', 1),
(93, 93, 'Civil', 'Local', 1),
(94, 94, 'Civil', 'Local', 1),
(95, 95, 'Civil', 'Local', 1),
(96, 96, 'Civil', 'Local', 1),
(97, 97, 'Civil', 'Local', 1),
(98, 98, 'Civil', 'Local', 1),
(99, 99, 'Civil', 'Local', 1),
(100, 100, 'Civil', 'Local', 1),
(101, 101, 'Civil', 'Local', 1),
(102, 102, 'Civil', 'Local', 1),
(103, 103, 'Civil', 'Local', 1),
(104, 104, 'Civil', 'Local', 1),
(105, 105, 'Civil', 'Local', 1),
(106, 106, 'Civil', 'Local', 1),
(107, 107, 'Civil', 'Local', 1),
(108, 108, 'Civil', 'Local', 1),
(109, 109, 'Civil', 'Local', 1),
(110, 110, 'Civil', 'Local', 1),
(111, 111, 'Civil', 'Local', 1),
(112, 112, 'Civil', 'Local', 1),
(113, 113, 'Civil', 'Local', 1),
(114, 114, 'Civil', 'Local', 1),
(115, 115, 'Civil', 'Local', 1),
(116, 116, 'Civil', 'Local', 1),
(117, 117, 'Civil', 'Local', 1),
(118, 118, 'Civil', 'Local', 1),
(119, 119, 'Civil', 'Local', 1),
(120, 120, 'Civil', 'Local', 1),
(121, 121, 'Civil', 'Local', 1),
(122, 122, 'Civil', 'Local', 1),
(123, 123, 'Civil', 'Local', 1),
(124, 124, 'Civil', 'Local', 1),
(125, 125, 'Civil', 'Local', 1),
(126, 126, 'Civil', 'Local', 1),
(127, 127, 'Civil', 'Local', 1),
(128, 128, 'Civil', 'Local', 1),
(129, 129, 'Civil', 'Local', 1),
(130, 130, 'Civil', 'Local', 1),
(131, 131, 'Civil', 'Local', 1),
(132, 132, 'Civil', 'Local', 1),
(133, 133, 'Civil', 'Local', 1),
(134, 134, 'Civil', 'Local', 1),
(135, 135, 'Civil', 'Local', 1),
(136, 136, 'Civil', 'Local', 1),
(137, 137, 'Civil', 'Local', 1),
(138, 138, 'Civil', 'Local', 1),
(139, 139, 'Civil', 'Local', 1),
(140, 140, 'Civil', 'Local', 1),
(141, 141, 'Civil', 'Local', 1),
(142, 142, 'Civil', 'Local', 1),
(143, 143, 'Civil', 'Local', 1),
(144, 144, 'Civil', 'Local', 1),
(145, 145, 'Civil', 'Local', 1),
(146, 146, 'Civil', 'Local', 1),
(147, 147, 'Civil', 'Local', 1),
(148, 148, 'Civil', 'Local', 1),
(149, 149, 'Civil', 'Local', 1),
(150, 150, 'Civil', 'Local', 1),
(151, 151, 'Civil', 'Local', 1),
(152, 152, 'Civil', 'Local', 1),
(153, 153, 'Civil', 'Local', 1),
(154, 154, 'Civil', 'Local', 1),
(155, 155, 'Civil', 'Local', 1),
(156, 156, 'Civil', 'District', 1),
(157, 26, 'Civil', 'District', 1),
(158, 113, 'Civil', 'District', 1),
(159, 116, 'Civil', 'District', 1),
(160, 2, 'Civil', 'District', 1),
(161, 3, 'Civil', 'District', 1),
(162, 9, 'Civil', 'District', 1),
(163, 10, 'Civil', 'District', 1),
(164, 18, 'Civil', 'District', 1),
(165, 22, 'Civil', 'District', 1),
(166, 32, 'Civil', 'District', 1),
(167, 36, 'Civil', 'District', 1),
(168, 44, 'Civil', 'District', 1),
(169, 47, 'Civil', 'District', 1),
(170, 56, 'Civil', 'District', 1),
(171, 57, 'Civil', 'District', 1),
(172, 58, 'Civil', 'District', 1),
(173, 60, 'Civil', 'District', 1),
(174, 79, 'Civil', 'District', 1),
(175, 90, 'Civil', 'District', 1),
(176, 105, 'Civil', 'District', 1),
(177, 108, 'Civil', 'District', 1),
(178, 111, 'Civil', 'District', 1),
(179, 112, 'Civil', 'District', 1),
(180, 119, 'Civil', 'District', 1),
(181, 157, 'Civil', 'District', 1),
(182, 130, 'Civil', 'District', 1),
(183, 131, 'Civil', 'District', 1),
(184, 138, 'Civil', 'District', 1),
(185, 151, 'Civil', 'District', 1),
(186, 158, 'Civil', 'Supreme', 1),
(187, 159, 'Criminal', 'Local', 1),
(188, 160, 'Criminal', 'Local', 1),
(189, 161, 'Criminal', 'Local', 1),
(190, 162, 'Criminal', 'Local', 1),
(191, 163, 'Criminal', 'Local', 1),
(192, 164, 'Criminal', 'Local', 1),
(193, 165, 'Criminal', 'Local', 1),
(194, 166, 'Criminal', 'Local', 1),
(195, 167, 'Criminal', 'Local', 1),
(196, 168, 'Criminal', 'Local', 1),
(197, 1, 'Criminal', 'Local', 1),
(198, 2, 'Criminal', 'Local', 1),
(199, 3, 'Criminal', 'Local', 1),
(200, 4, 'Criminal', 'Local', 1),
(201, 5, 'Criminal', 'Local', 1),
(202, 6, 'Criminal', 'Local', 1),
(203, 7, 'Criminal', 'Local', 1),
(204, 8, 'Criminal', 'Local', 1),
(205, 9, 'Criminal', 'Local', 1),
(206, 10, 'Criminal', 'Local', 1),
(207, 11, 'Criminal', 'Local', 1),
(208, 12, 'Criminal', 'Local', 1),
(209, 13, 'Criminal', 'Local', 1),
(210, 14, 'Criminal', 'Local', 1),
(211, 15, 'Criminal', 'Local', 1),
(212, 16, 'Criminal', 'Local', 1),
(213, 17, 'Criminal', 'Local', 1),
(214, 18, 'Criminal', 'Local', 1),
(215, 19, 'Criminal', 'Local', 1),
(216, 20, 'Criminal', 'Local', 1),
(217, 21, 'Criminal', 'Local', 1),
(218, 22, 'Criminal', 'Local', 1),
(219, 23, 'Criminal', 'Local', 1),
(220, 24, 'Criminal', 'Local', 1),
(221, 25, 'Criminal', 'Local', 1),
(222, 26, 'Criminal', 'Local', 1),
(223, 27, 'Criminal', 'Local', 1),
(224, 28, 'Criminal', 'Local', 1),
(225, 29, 'Criminal', 'Local', 1),
(226, 30, 'Criminal', 'Local', 1),
(227, 31, 'Criminal', 'Local', 1),
(228, 32, 'Criminal', 'Local', 1),
(229, 33, 'Criminal', 'Local', 1),
(230, 34, 'Criminal', 'Local', 1),
(231, 35, 'Criminal', 'Local', 1),
(232, 36, 'Criminal', 'Local', 1),
(233, 37, 'Criminal', 'Local', 1),
(234, 38, 'Criminal', 'Local', 1),
(235, 39, 'Criminal', 'Local', 1),
(236, 40, 'Criminal', 'Local', 1),
(237, 41, 'Criminal', 'Local', 1),
(238, 169, 'Criminal', 'Local', 1),
(239, 43, 'Criminal', 'Local', 1),
(240, 44, 'Criminal', 'Local', 1),
(241, 45, 'Criminal', 'Local', 1),
(242, 46, 'Criminal', 'Local', 1),
(243, 47, 'Criminal', 'Local', 1),
(244, 48, 'Criminal', 'Local', 1),
(245, 49, 'Criminal', 'Local', 1),
(246, 50, 'Criminal', 'Local', 1),
(247, 51, 'Criminal', 'Local', 1),
(248, 52, 'Criminal', 'Local', 1),
(249, 53, 'Criminal', 'Local', 1),
(250, 54, 'Criminal', 'Local', 1),
(251, 55, 'Criminal', 'Local', 1),
(252, 56, 'Criminal', 'Local', 1),
(253, 57, 'Criminal', 'Local', 1),
(254, 58, 'Criminal', 'Local', 1),
(255, 59, 'Criminal', 'Local', 1),
(256, 60, 'Criminal', 'Local', 1),
(257, 61, 'Criminal', 'Local', 1),
(258, 62, 'Criminal', 'Local', 1),
(259, 63, 'Criminal', 'Local', 1),
(260, 64, 'Criminal', 'Local', 1),
(261, 65, 'Criminal', 'Local', 1),
(262, 66, 'Criminal', 'Local', 1),
(263, 67, 'Criminal', 'Local', 1),
(264, 68, 'Criminal', 'Local', 1),
(265, 69, 'Criminal', 'Local', 1),
(266, 70, 'Criminal', 'Local', 1),
(267, 71, 'Criminal', 'Local', 1),
(268, 72, 'Criminal', 'Local', 1),
(269, 73, 'Criminal', 'Local', 1),
(270, 74, 'Criminal', 'Local', 1),
(271, 75, 'Criminal', 'Local', 1),
(272, 76, 'Criminal', 'Local', 1),
(273, 77, 'Criminal', 'Local', 1),
(274, 78, 'Criminal', 'Local', 1),
(275, 79, 'Criminal', 'Local', 1),
(276, 80, 'Criminal', 'Local', 1),
(277, 81, 'Criminal', 'Local', 1),
(278, 82, 'Criminal', 'Local', 1),
(279, 83, 'Criminal', 'Local', 1),
(280, 84, 'Criminal', 'Local', 1),
(281, 85, 'Criminal', 'Local', 1),
(282, 86, 'Criminal', 'Local', 1),
(283, 87, 'Criminal', 'Local', 1),
(284, 88, 'Criminal', 'Local', 1),
(285, 89, 'Criminal', 'Local', 1),
(286, 90, 'Criminal', 'Local', 1),
(287, 91, 'Criminal', 'Local', 1),
(288, 92, 'Criminal', 'Local', 1),
(289, 93, 'Criminal', 'Local', 1),
(290, 94, 'Criminal', 'Local', 1),
(291, 95, 'Criminal', 'Local', 1),
(292, 96, 'Criminal', 'Local', 1),
(293, 97, 'Criminal', 'Local', 1),
(294, 98, 'Criminal', 'Local', 1),
(295, 99, 'Criminal', 'Local', 1),
(296, 100, 'Criminal', 'Local', 1),
(297, 101, 'Criminal', 'Local', 1),
(298, 102, 'Criminal', 'Local', 1),
(299, 103, 'Criminal', 'Local', 1),
(300, 104, 'Criminal', 'Local', 1),
(301, 105, 'Criminal', 'Local', 1),
(302, 106, 'Criminal', 'Local', 1),
(303, 107, 'Criminal', 'Local', 1),
(304, 108, 'Criminal', 'Local', 1),
(305, 109, 'Criminal', 'Local', 1),
(306, 110, 'Criminal', 'Local', 1),
(307, 111, 'Criminal', 'Local', 1),
(308, 112, 'Criminal', 'Local', 1),
(309, 113, 'Criminal', 'Local', 1),
(310, 114, 'Criminal', 'Local', 1),
(311, 115, 'Criminal', 'Local', 1),
(312, 116, 'Criminal', 'Local', 1),
(313, 117, 'Criminal', 'Local', 1),
(314, 118, 'Criminal', 'Local', 1),
(315, 119, 'Criminal', 'Local', 1),
(316, 120, 'Criminal', 'Local', 1),
(317, 121, 'Criminal', 'Local', 1),
(318, 122, 'Criminal', 'Local', 1),
(319, 123, 'Criminal', 'Local', 1),
(320, 124, 'Criminal', 'Local', 1),
(321, 125, 'Criminal', 'Local', 1),
(322, 126, 'Criminal', 'Local', 1),
(323, 127, 'Criminal', 'Local', 1),
(324, 128, 'Criminal', 'Local', 1),
(325, 129, 'Criminal', 'Local', 1),
(326, 130, 'Criminal', 'Local', 1),
(327, 131, 'Criminal', 'Local', 1),
(328, 132, 'Criminal', 'Local', 1),
(329, 133, 'Criminal', 'Local', 1),
(330, 134, 'Criminal', 'Local', 1),
(331, 135, 'Criminal', 'Local', 1),
(332, 136, 'Criminal', 'Local', 1),
(333, 137, 'Criminal', 'Local', 1),
(334, 138, 'Criminal', 'Local', 1),
(335, 139, 'Criminal', 'Local', 1),
(336, 140, 'Criminal', 'Local', 1),
(337, 141, 'Criminal', 'Local', 1),
(338, 142, 'Criminal', 'Local', 1),
(339, 143, 'Criminal', 'Local', 1),
(340, 144, 'Criminal', 'Local', 1),
(341, 145, 'Criminal', 'Local', 1),
(342, 146, 'Criminal', 'Local', 1),
(343, 147, 'Criminal', 'Local', 1),
(344, 148, 'Criminal', 'Local', 1),
(345, 149, 'Criminal', 'Local', 1),
(346, 150, 'Criminal', 'Local', 1),
(347, 151, 'Criminal', 'Local', 1),
(348, 152, 'Criminal', 'Local', 1),
(349, 153, 'Criminal', 'Local', 1),
(350, 154, 'Criminal', 'Local', 1),
(351, 155, 'Criminal', 'Local', 1),
(352, 156, 'Criminal', 'District', 1),
(353, 26, 'Criminal', 'District', 1),
(354, 113, 'Criminal', 'District', 1),
(355, 116, 'Criminal', 'District', 1),
(356, 2, 'Criminal', 'District', 1),
(357, 3, 'Criminal', 'District', 1),
(358, 9, 'Criminal', 'District', 1),
(359, 10, 'Criminal', 'District', 1),
(360, 18, 'Criminal', 'District', 1),
(361, 22, 'Criminal', 'District', 1),
(362, 32, 'Criminal', 'District', 1),
(363, 36, 'Criminal', 'District', 1),
(364, 44, 'Criminal', 'District', 1),
(365, 47, 'Criminal', 'District', 1),
(366, 56, 'Criminal', 'District', 1),
(367, 57, 'Criminal', 'District', 1),
(368, 58, 'Criminal', 'District', 1),
(369, 60, 'Criminal', 'District', 1),
(370, 79, 'Criminal', 'District', 1),
(371, 90, 'Criminal', 'District', 1),
(372, 105, 'Criminal', 'District', 1),
(373, 108, 'Criminal', 'District', 1),
(374, 111, 'Criminal', 'District', 1),
(375, 112, 'Criminal', 'District', 1),
(376, 119, 'Criminal', 'District', 1),
(377, 157, 'Criminal', 'District', 1),
(378, 130, 'Criminal', 'District', 1),
(379, 131, 'Criminal', 'District', 1),
(380, 138, 'Criminal', 'District', 1),
(381, 151, 'Criminal', 'District', 1),
(382, 158, 'Criminal', 'Supreme', 1),
(383, 170, 'Environmental', 'District', 1),
(384, 158, 'Environmental', 'Supreme', 1),
(385, 171, 'Family', 'Local', 1),
(386, 172, 'Family', 'Local', 1),
(387, 2, 'Family', 'District', 1),
(388, 3, 'Family', 'District', 1),
(389, 22, 'Family', 'District', 1),
(390, 32, 'Family', 'District', 1),
(391, 44, 'Family', 'District', 1),
(392, 79, 'Family', 'District', 1),
(393, 111, 'Family', 'District', 1),
(394, 119, 'Family', 'District', 1),
(395, 130, 'Family', 'District', 1),
(396, 138, 'Family', 'District', 1),
(397, 173, 'Family', 'District', 1),
(398, 158, 'Family', 'Supreme', 1),
(399, 174, 'Family', 'Local', 1);
-- --------------------------------------------------------
--
-- Table structure for table `favorites`
--
CREATE TABLE IF NOT EXISTS `favorites` (
`id` bigint(11) unsigned NOT NULL,
`associate_id` bigint(20) unsigned NOT NULL,
`other_associate_id` bigint(20) unsigned NOT NULL,
`insert_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `favorites`
--
INSERT INTO `favorites` (`id`, `associate_id`, `other_associate_id`, `insert_time`) VALUES
(1, 12, 8, '2015-07-28 09:46:36'),
(4, 8, 12, '2015-07-28 09:48:02'),
(5, 12, 2, '2015-07-28 09:48:15'),
(6, 12, 3, '2015-07-28 09:53:20'),
(8, 8, 4, '2015-07-28 10:03:46'),
(9, 12, 10, '2015-08-01 20:56:02'),
(11, 2, 1, '2015-08-03 20:35:07'),
(12, 15, 11, '2015-08-10 08:52:28'),
(13, 15, 9, '2015-08-10 08:52:42'),
(14, 14, 13, '2015-08-19 03:22:28'),
(15, 19, 14, '2015-08-27 01:29:51'),
(16, 8, 1, '2015-10-20 08:30:37'),
(18, 9, 12, '2015-11-18 05:10:31'),
(19, 8, 21, '2016-01-15 11:26:59'),
(20, 25, 5, '2016-02-03 01:08:43'),
(27, 35, 2, '2016-04-16 05:55:02');
-- --------------------------------------------------------
--
-- Table structure for table `message_inboxes`
--
CREATE TABLE IF NOT EXISTS `message_inboxes` (
`id` bigint(11) unsigned NOT NULL,
`sender_associate_id` bigint(11) unsigned NOT NULL DEFAULT '0',
`receiver_associate_id` bigint(20) unsigned NOT NULL DEFAULT '0',
`channel` char(50) NOT NULL DEFAULT '',
`message` text NOT NULL,
`insert_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`update_time` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `message_inboxes`
--
INSERT INTO `message_inboxes` (`id`, `sender_associate_id`, `receiver_associate_id`, `channel`, `message`, `insert_time`, `update_time`) VALUES
(1, 8, 1, 'Channel_1-8', 'Hey there', '2015-07-26 06:47:12', '2015-10-06 06:38:53'),
(2, 1, 6, 'Channel_1-6', 'Hi', '2015-07-26 08:03:27', '2015-07-26 08:03:27'),
(3, 12, 8, 'Channel_8-12', 'Hello', '2015-07-27 20:50:43', '2015-10-06 06:32:23'),
(4, 12, 1, 'Channel_1-12', 'Hi', '2015-08-04 06:30:02', '2015-08-04 06:30:02'),
(5, 9, 10, 'Channel_9-10', 'Testing testing', '2015-08-04 09:03:15', '2015-08-04 09:03:20'),
(6, 8, 9, 'Channel_8-9', 'Will you be at Central Court this morning by chance?', '2015-08-04 22:34:36', '2015-08-13 21:58:19'),
(7, 15, 9, 'Channel_9-15', 'Hey are you getting these messages ?', '2015-08-10 08:53:06', '2015-08-10 09:10:22'),
(8, 15, 11, 'Channel_11-15', 'Hi Norin are you getting these messages', '2015-08-10 09:11:08', '2015-08-10 09:11:08'),
(9, 14, 12, 'Channel_12-14', 'Sabi ni kd you people doesnt want to deal with me kaya i fired myself for this but still they asked me to finish this', '2015-08-14 03:49:58', '2015-11-27 07:35:53'),
(10, 14, 13, 'Channel_13-14', 'Hello need your feedbacks on that modification list, asap', '2015-08-17 05:49:49', '2015-08-17 05:49:49'),
(11, 19, 17, 'Channel_17-19', 'Hi', '2015-08-27 01:27:01', '2015-08-27 01:27:01'),
(12, 20, 20, 'Channel_20-20', '??', '2015-09-08 02:48:57', '2015-09-08 02:49:17'),
(13, 13, 9, 'Channel_9-13', 'Hi Chayana', '2015-10-06 06:25:01', '2015-10-06 06:25:01'),
(14, 13, 8, 'Channel_8-13', 'Testing for build #7', '2015-10-06 07:14:47', '2016-01-15 11:21:34'),
(15, 26, 9, 'Channel_9-26', 'Hey', '2016-01-27 23:53:39', '2016-01-28 07:15:59');
-- --------------------------------------------------------
--
-- Table structure for table `migrations`
--
CREATE TABLE IF NOT EXISTS `migrations` (
`migration` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`batch` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Dumping data for table `migrations`
--
INSERT INTO `migrations` (`migration`, `batch`) VALUES
('2014_04_24_110151_create_oauth_scopes_table', 1),
('2014_04_24_110304_create_oauth_grants_table', 1),
('2014_04_24_110403_create_oauth_grant_scopes_table', 1),
('2014_04_24_110459_create_oauth_clients_table', 1),
('2014_04_24_110557_create_oauth_client_endpoints_table', 1),
('2014_04_24_110705_create_oauth_client_scopes_table', 1),
('2014_04_24_110817_create_oauth_client_grants_table', 1),
('2014_04_24_111002_create_oauth_sessions_table', 1),
('2014_04_24_111109_create_oauth_session_scopes_table', 1),
('2014_04_24_111254_create_oauth_auth_codes_table', 1),
('2014_04_24_111403_create_oauth_auth_code_scopes_table', 1),
('2014_04_24_111518_create_oauth_access_tokens_table', 1),
('2014_04_24_111657_create_oauth_access_token_scopes_table', 1),
('2014_04_24_111810_create_oauth_refresh_tokens_table', 1),
('2014_10_12_000000_create_users_table', 1),
('2014_10_12_100000_create_password_resets_table', 1);
-- --------------------------------------------------------
--
-- Table structure for table `notifications`
--
CREATE TABLE IF NOT EXISTS `notifications` (
`id` bigint(11) unsigned NOT NULL,
`associate_id` bigint(11) unsigned NOT NULL,
`other_associate_id` bigint(11) unsigned NOT NULL,
`notification_type` int(11) unsigned NOT NULL,
`insert_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB AUTO_INCREMENT=112 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `notifications`
--
INSERT INTO `notifications` (`id`, `associate_id`, `other_associate_id`, `notification_type`, `insert_time`) VALUES
(1, 8, 1, 3, '2015-07-27 20:06:50'),
(2, 8, 1, 3, '2015-07-27 20:08:56'),
(3, 8, 12, 3, '2015-07-27 20:53:38'),
(4, 12, 8, 7, '2015-07-27 21:24:09'),
(5, 2, 12, 3, '2015-07-28 09:43:16'),
(6, 12, 8, 1, '2015-07-28 09:46:36'),
(7, 8, 12, 2, '2015-07-28 09:46:36'),
(8, 12, 1, 1, '2015-07-28 09:46:52'),
(9, 1, 12, 2, '2015-07-28 09:46:52'),
(10, 8, 1, 1, '2015-07-28 09:47:19'),
(11, 1, 8, 2, '2015-07-28 09:47:19'),
(12, 8, 12, 1, '2015-07-28 09:48:02'),
(13, 12, 8, 2, '2015-07-28 09:48:02'),
(14, 12, 2, 1, '2015-07-28 09:48:15'),
(15, 2, 12, 2, '2015-07-28 09:48:15'),
(16, 12, 3, 1, '2015-07-28 09:53:20'),
(17, 3, 12, 2, '2015-07-28 09:53:20'),
(18, 12, 5, 1, '2015-07-28 10:02:09'),
(19, 5, 12, 2, '2015-07-28 10:02:09'),
(20, 8, 4, 1, '2015-07-28 10:03:46'),
(21, 4, 8, 2, '2015-07-28 10:03:46'),
(22, 1, 8, 3, '2015-07-30 17:13:42'),
(23, 5, 8, 3, '2015-07-30 17:13:42'),
(24, 2, 8, 3, '2015-07-30 17:13:42'),
(25, 5, 8, 6, '2015-07-30 17:14:20'),
(26, 2, 8, 6, '2015-07-30 17:14:20'),
(27, 8, 1, 7, '2015-07-30 17:14:20'),
(28, 1, 8, 3, '2015-08-01 15:25:43'),
(29, 8, 1, 7, '2015-08-01 15:26:32'),
(30, 2, 12, 3, '2015-08-01 16:55:00'),
(31, 11, 12, 3, '2015-08-01 16:55:00'),
(32, 12, 10, 1, '2015-08-01 20:56:03'),
(33, 10, 12, 2, '2015-08-01 20:56:03'),
(34, 2, 1, 1, '2015-08-03 03:56:58'),
(35, 1, 2, 2, '2015-08-03 03:56:58'),
(36, 1, 2, 3, '2015-08-03 03:57:45'),
(37, 2, 1, 7, '2015-08-03 03:59:05'),
(38, 2, 1, 1, '2015-08-03 20:35:07'),
(39, 1, 2, 2, '2015-08-03 20:35:07'),
(40, 8, 12, 3, '2015-08-03 21:28:15'),
(41, 12, 8, 7, '2015-08-03 22:15:54'),
(42, 5, 12, 3, '2015-08-04 06:21:33'),
(43, 3, 12, 3, '2015-08-04 06:21:33'),
(44, 4, 12, 3, '2015-08-04 06:21:33'),
(45, 5, 12, 6, '2015-08-04 06:22:51'),
(46, 4, 12, 6, '2015-08-04 06:22:51'),
(47, 12, 3, 7, '2015-08-04 06:22:51'),
(48, 12, 14, 3, '2015-08-04 06:38:53'),
(49, 14, 12, 7, '2015-08-04 06:40:14'),
(50, 14, 12, 9, '2015-08-04 06:42:12'),
(51, 3, 14, 3, '2015-08-04 06:43:17'),
(52, 14, 3, 7, '2015-08-04 06:43:40'),
(53, 9, 14, 3, '2015-08-04 07:30:37'),
(54, 9, 8, 3, '2015-08-04 23:39:25'),
(55, 8, 9, 7, '2015-08-04 23:40:46'),
(56, 8, 9, 4, '2015-08-05 01:46:22'),
(57, 9, 8, 3, '2015-08-10 05:05:05'),
(58, 8, 9, 7, '2015-08-10 05:05:42'),
(59, 15, 11, 1, '2015-08-10 08:52:28'),
(60, 11, 15, 2, '2015-08-10 08:52:28'),
(61, 15, 9, 1, '2015-08-10 08:52:42'),
(62, 9, 15, 2, '2015-08-10 08:52:42'),
(63, 11, 15, 3, '2015-08-10 09:14:45'),
(64, 9, 15, 3, '2015-08-10 09:15:25'),
(65, 8, 9, 4, '2015-08-11 02:26:32'),
(66, 15, 9, 15, '2015-08-11 02:27:50'),
(67, 12, 14, 3, '2015-08-14 03:49:26'),
(68, 13, 14, 3, '2015-08-17 05:47:31'),
(69, 4, 17, 3, '2015-08-18 08:49:55'),
(70, 11, 17, 3, '2015-08-18 08:50:52'),
(71, 2, 17, 3, '2015-08-18 08:52:59'),
(72, 1, 17, 3, '2015-08-18 08:57:32'),
(73, 16, 17, 3, '2015-08-18 09:20:08'),
(74, 14, 13, 1, '2015-08-19 03:22:28'),
(75, 13, 14, 2, '2015-08-19 03:22:28'),
(76, 17, 19, 3, '2015-08-27 01:26:34'),
(77, 19, 14, 1, '2015-08-27 01:29:51'),
(78, 14, 19, 2, '2015-08-27 01:29:51'),
(79, 17, 14, 3, '2015-08-27 05:23:51'),
(80, 14, 20, 3, '2015-09-07 05:44:56'),
(81, 14, 20, 3, '2015-09-07 05:47:50'),
(82, 14, 20, 3, '2015-09-08 00:57:02'),
(83, 20, 17, 1, '2015-09-08 02:48:25'),
(84, 17, 20, 2, '2015-09-08 02:48:25'),
(85, 20, 17, 1, '2015-09-08 02:48:33'),
(86, 17, 20, 2, '2015-09-08 02:48:33'),
(87, 17, 20, 3, '2015-09-08 02:50:46'),
(88, 11, 20, 3, '2015-09-08 03:39:11'),
(89, 20, 14, 3, '2015-09-11 04:09:03'),
(90, 20, 17, 1, '2015-09-14 05:53:34'),
(91, 17, 20, 2, '2015-09-14 05:53:34'),
(92, 8, 1, 1, '2015-10-20 08:30:37'),
(93, 1, 8, 2, '2015-10-20 08:30:38'),
(94, 9, 12, 1, '2015-11-18 05:10:08'),
(95, 12, 9, 2, '2015-11-18 05:10:08'),
(96, 9, 12, 1, '2015-11-18 05:10:31'),
(97, 12, 9, 2, '2015-11-18 05:10:31'),
(98, 12, 14, 3, '2015-11-27 07:37:04'),
(99, 1, 8, 5, '2016-01-15 11:23:54'),
(100, 1, 8, 5, '2016-01-15 11:24:12'),
(101, 12, 8, 3, '2016-01-15 11:26:18'),
(102, 8, 21, 1, '2016-01-15 11:26:59'),
(103, 21, 8, 2, '2016-01-15 11:26:59'),
(104, 21, 8, 3, '2016-01-15 11:28:16'),
(105, 26, 9, 3, '2016-01-27 23:41:19'),
(106, 9, 26, 3, '2016-01-27 23:59:08'),
(107, 25, 5, 1, '2016-02-03 01:08:43'),
(108, 5, 25, 2, '2016-02-03 01:08:43'),
(109, 12, 8, 3, '2016-02-11 10:04:07'),
(110, 23, 8, 3, '2016-02-11 10:05:11'),
(111, 8, 23, 7, '2016-02-11 10:07:37');
-- --------------------------------------------------------
--
-- Table structure for table `oauth_access_tokens`
--
CREATE TABLE IF NOT EXISTS `oauth_access_tokens` (
`id` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
`session_id` int(10) unsigned NOT NULL,
`expire_time` int(11) NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Dumping data for table `oauth_access_tokens`
--
INSERT INTO `oauth_access_tokens` (`id`, `session_id`, `expire_time`, `created_at`, `updated_at`) VALUES
('1HlNxIheZdTfqb2kay1Y3NDdmXj6cxgdJET3I980', 2, 1459873319, '2016-04-05 07:21:59', '2016-04-05 07:21:59'),
('5jAFaN4XtLdZyen5GL32vskj6MGJ1YLx4wR8YZvs', 3, 1459874983, '2016-04-05 07:49:43', '2016-04-05 07:49:43'),
('AjOuQiUPrnD72aHtjcbFp1WjdywTT0JmwcvpcZX5', 9, 1460125201, '2016-04-08 05:20:01', '2016-04-08 05:20:01'),
('amcA8znOPRQepAvpgSMcVwSdCbDZcKUVA0KAL0PU', 4, 1459876261, '2016-04-05 08:11:01', '2016-04-05 08:11:01'),
('e97KC7cuOWNtXEPrG2UxP7h48MeTtuVpZ8fFsHjk', 10, 1460127974, '2016-04-08 06:06:14', '2016-04-08 06:06:14'),
('eFZ641BNFTzMt67QuFxXEyzj1EMysFIBLse80b5T', 6, 1460124514, '2016-04-08 05:08:34', '2016-04-08 05:08:34'),
('g5z8fNjUkw0DkFmyM3YzgJ36wqOptLPnTThA2JcD', 8, 1460125200, '2016-04-08 05:20:00', '2016-04-08 05:20:00'),
('PhqsTUenHz11yrFcr8ysoyn6RQWoeEKF1UeSxA9l', 5, 1459925992, '2016-04-05 21:59:52', '2016-04-05 21:59:52'),
('tc3VxeAwr3DaFngEYn6ndfpfdg2ttlC8rU1KjIrk', 7, 1460125197, '2016-04-08 05:19:57', '2016-04-08 05:19:57'),
('ZuxyQP9nSKpjatYVkEhHdhXUPBplaVNutt1XKMDj', 1, 1459866281, '2016-04-05 05:24:41', '2016-04-05 05:24:41');
-- --------------------------------------------------------
--
-- Table structure for table `oauth_access_token_scopes`
--
CREATE TABLE IF NOT EXISTS `oauth_access_token_scopes` (
`id` int(10) unsigned NOT NULL,
`access_token_id` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
`scope_id` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `oauth_auth_codes`
--
CREATE TABLE IF NOT EXISTS `oauth_auth_codes` (
`id` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
`session_id` int(10) unsigned NOT NULL,
`redirect_uri` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`expire_time` int(11) NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `oauth_auth_code_scopes`
--
CREATE TABLE IF NOT EXISTS `oauth_auth_code_scopes` (
`id` int(10) unsigned NOT NULL,
`auth_code_id` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
`scope_id` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `oauth_clients`
--
CREATE TABLE IF NOT EXISTS `oauth_clients` (
`id` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
`secret` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
`name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Dumping data for table `oauth_clients`
--
INSERT INTO `oauth_clients` (`id`, `secret`, `name`, `created_at`, `updated_at`) VALUES
('1', '1', 'Test', NULL, NULL),
('f3d259ddd3ed8ff3843839b', '4c7f6f8fa93d59c45502c0ae8c4a95b', 'Main website', '0000-00-00 00:00:00', '0000-00-00 00:00:00');
-- --------------------------------------------------------
--
-- Table structure for table `oauth_client_endpoints`
--
CREATE TABLE IF NOT EXISTS `oauth_client_endpoints` (
`id` int(10) unsigned NOT NULL,
`client_id` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
`redirect_uri` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `oauth_client_grants`
--
CREATE TABLE IF NOT EXISTS `oauth_client_grants` (
`id` int(10) unsigned NOT NULL,
`client_id` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
`grant_id` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `oauth_client_scopes`
--
CREATE TABLE IF NOT EXISTS `oauth_client_scopes` (
`id` int(10) unsigned NOT NULL,
`client_id` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
`scope_id` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `oauth_grants`
--
CREATE TABLE IF NOT EXISTS `oauth_grants` (
`id` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `oauth_grant_scopes`
--
CREATE TABLE IF NOT EXISTS `oauth_grant_scopes` (
`id` int(10) unsigned NOT NULL,
`grant_id` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
`scope_id` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `oauth_refresh_tokens`
--
CREATE TABLE IF NOT EXISTS `oauth_refresh_tokens` (
`id` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
`access_token_id` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
`expire_time` int(11) NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `oauth_scopes`
--
CREATE TABLE IF NOT EXISTS `oauth_scopes` (
`id` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
`description` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `oauth_sessions`
--
CREATE TABLE IF NOT EXISTS `oauth_sessions` (
`id` int(10) unsigned NOT NULL,
`client_id` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
`owner_type` enum('client','user') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'user',
`owner_id` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`client_redirect_uri` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Dumping data for table `oauth_sessions`
--
INSERT INTO `oauth_sessions` (`id`, `client_id`, `owner_type`, `owner_id`, `client_redirect_uri`, `created_at`, `updated_at`) VALUES
(1, '1', 'user', '2', NULL, '2016-04-05 05:24:41', '2016-04-05 05:24:41'),
(2, '1', 'user', '2', NULL, '2016-04-05 07:21:59', '2016-04-05 07:21:59'),
(3, '1', 'user', '2', NULL, '2016-04-05 07:49:43', '2016-04-05 07:49:43'),
(4, '1', 'user', '2', NULL, '2016-04-05 08:11:01', '2016-04-05 08:11:01'),
(5, '1', 'user', '2', NULL, '2016-04-05 21:59:52', '2016-04-05 21:59:52'),
(6, '1', 'user', '2', NULL, '2016-04-08 05:08:34', '2016-04-08 05:08:34'),
(7, '1', 'user', '2', NULL, '2016-04-08 05:19:57', '2016-04-08 05:19:57'),
(8, '1', 'user', '2', NULL, '2016-04-08 05:20:00', '2016-04-08 05:20:00'),
(9, '1', 'user', '2', NULL, '2016-04-08 05:20:01', '2016-04-08 05:20:01'),
(10, '1', 'user', '2', NULL, '2016-04-08 06:06:14', '2016-04-08 06:06:14');
-- --------------------------------------------------------
--
-- Table structure for table `oauth_session_scopes`
--
CREATE TABLE IF NOT EXISTS `oauth_session_scopes` (
`id` int(10) unsigned NOT NULL,
`session_id` int(10) unsigned NOT NULL,
`scope_id` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `password_resets`
--
CREATE TABLE IF NOT EXISTS `password_resets` (
`email` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`token` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `request_types`
--
CREATE TABLE IF NOT EXISTS `request_types` (
`id` bigint(11) unsigned NOT NULL,
`name` char(50) NOT NULL DEFAULT '',
`description` char(255) NOT NULL DEFAULT '',
`insert_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `request_types`
--
INSERT INTO `request_types` (`id`, `name`, `description`, `insert_time`) VALUES
(1, 'Arbitration', '', '2015-07-03 11:20:11'),
(2, 'Arraignment', '', '2015-07-03 11:22:15'),
(3, 'Bail', '', '2015-07-03 11:22:32'),
(4, 'Call-over', '', '2015-07-03 11:22:51'),
(5, 'Directions', '', '2015-07-03 11:50:36'),
(6, 'Duty Judge', '', '2015-07-03 11:50:44'),
(7, 'Examination', '', '2015-07-03 11:50:49'),
(8, 'Hearing', '', '2015-07-03 11:50:57'),
(9, 'Judgment', '', '2015-07-03 11:51:02'),
(10, 'Mediation', '', '2015-07-03 11:51:07'),
(11, 'Mention', '', '2015-07-03 11:51:12'),
(12, 'Motion', '', '2015-07-03 11:51:18'),
(13, 'Return of subpoena', '', '2015-07-03 11:51:24'),
(14, 'Review', '', '2015-07-03 11:51:29'),
(15, 'Sentence', '', '2015-07-03 11:51:33'),
(16, 'Special Fixture', '', '2015-07-03 11:51:40'),
(17, 'Trial', '', '2015-07-03 11:51:46');
-- --------------------------------------------------------
--
-- Table structure for table `schedules`
--
CREATE TABLE IF NOT EXISTS `schedules` (
`id` bigint(11) unsigned NOT NULL,
`court_detail_id` bigint(11) unsigned NOT NULL,
`associate_id` bigint(11) unsigned NOT NULL,
`date_time` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`request_type_id` bigint(11) unsigned NOT NULL,
`notes` char(255) NOT NULL DEFAULT '',
`insert_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB AUTO_INCREMENT=71 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `schedules`
--
INSERT INTO `schedules` (`id`, `court_detail_id`, `associate_id`, `date_time`, `request_type_id`, `notes`, `insert_time`) VALUES
(1, 1, 8, '2015-07-28 06:02:52', 7, 'Some notes', '2015-07-27 20:03:26'),
(2, 1, 1, '2015-07-28 06:06:33', 4, '', '2015-07-27 20:06:50'),
(3, 1, 1, '2015-07-29 06:00:00', 7, '', '2015-07-27 20:08:56'),
(4, 352, 12, '2015-07-27 21:51:07', 14, 'Case lorem ipsum agb vs phil coulson', '2015-07-27 20:53:38'),
(5, 197, 12, '2015-07-29 16:00:00', 5, 'Blah blah', '2015-07-28 06:23:49'),
(6, 205, 12, '2015-07-28 10:34:12', 7, 'Asdfghjjbvccxddghjhfc', '2015-07-28 09:43:15'),
(7, 1, 8, '2015-07-28 10:45:15', 4, '', '2015-07-28 10:38:43'),
(9, 1, 8, '2015-07-30 18:16:13', 4, '', '2015-07-30 17:16:20'),
(10, 1, 1, '2015-08-01 15:30:45', 1, '', '2015-08-01 15:24:02'),
(12, 2, 8, '2015-08-02 04:35:53', 12, 'Notes and notes\nAnd more notes', '2015-08-01 16:36:42'),
(13, 1, 12, '2015-08-28 02:00:00', 7, 'Case details here', '2015-08-01 16:55:00'),
(14, 221, 2, '2015-08-20 16:00:00', 4, '', '2015-08-03 03:57:44'),
(15, 203, 12, '2015-08-05 06:00:00', 5, 'I need a rep for this case no. 12345 defendant Jason Bourne', '2015-08-03 21:28:14'),
(16, 1, 12, '2015-08-05 06:19:00', 1, 'Hello pls accept my request\n', '2015-08-04 06:21:33'),
(17, 399, 3, '2015-08-04 07:25:02', 5, '', '2015-08-04 06:25:20'),
(18, 198, 12, '2015-08-13 08:00:00', 4, '', '2015-08-04 06:34:22'),
(19, 386, 14, '2015-08-04 07:38:22', 3, 'Test me\n', '2015-08-04 06:38:53'),
(20, 200, 14, '2015-08-04 08:29:51', 2, 'Test me', '2015-08-04 07:30:37'),
(21, 238, 9, '2015-08-04 14:00:00', 11, 'Matter of Michael Mate', '2015-08-04 09:00:07'),
(22, 205, 8, '2015-08-05 23:36:37', 3, '', '2015-08-04 22:37:17'),
(24, 238, 8, '2015-08-05 01:38:57', 2, 'Can you do this ?', '2015-08-04 23:39:25'),
(25, 238, 9, '2015-08-10 06:03:23', 11, 'Available for mentions', '2015-08-10 05:04:09'),
(26, 238, 8, '2015-08-10 06:04:43', 11, 'Yes I can', '2015-08-10 05:05:05'),
(27, 199, 15, '2015-08-16 13:13:34', 6, 'Can you be here ?', '2015-08-10 09:14:45'),
(28, 197, 15, '2015-08-16 13:14:52', 9, 'Will you be here', '2015-08-10 09:15:25'),
(29, 199, 14, '2015-08-14 04:47:12', 8, 'Need updates and i emailed you????', '2015-08-14 03:48:03'),
(30, 199, 14, '2015-08-14 04:48:39', 8, 'Need update and i need the artworks', '2015-08-14 03:49:26'),
(31, 3, 14, '2015-08-17 06:46:26', 10, 'Mediation with our pricing, asap please.', '2015-08-17 05:47:31'),
(32, 1, 17, '2015-08-18 09:49:29', 2, '', '2015-08-18 08:49:55'),
(33, 1, 17, '2015-08-18 09:50:24', 1, '', '2015-08-18 08:50:52'),
(34, 197, 17, '2015-08-18 09:52:32', 1, 'Be there', '2015-08-18 08:52:59'),
(35, 1, 17, '2015-08-22 20:09:46', 1, 'Please be there', '2015-08-18 08:57:32'),
(36, 197, 17, '2015-08-18 10:19:36', 2, 'Sample', '2015-08-18 09:20:02'),
(37, 399, 13, '2015-08-19 04:09:31', 1, '', '2015-08-19 03:10:15'),
(38, 1, 8, '2015-08-21 00:25:55', 1, 'sample', '2015-08-20 23:26:07'),
(39, 213, 19, '2015-08-27 02:22:17', 11, '', '2015-08-27 01:23:07'),
(40, 213, 19, '2015-08-27 02:22:17', 11, '', '2015-08-27 01:23:08'),
(41, 399, 19, '2015-08-27 02:26:08', 5, '', '2015-08-27 01:26:34'),
(42, 399, 19, '2015-08-27 02:31:03', 3, 'Hahsjjsis\n', '2015-08-27 01:31:24'),
(43, 399, 14, '2015-08-27 06:23:20', 1, 'Proceed', '2015-08-27 05:23:51'),
(44, 399, 20, '2015-09-07 06:43:53', 5, '', '2015-09-07 05:44:55'),
(45, 399, 20, '2015-09-29 16:00:00', 12, '', '2015-09-07 05:47:49'),
(46, 399, 20, '2015-09-08 01:56:50', 3, '', '2015-09-08 00:57:01'),
(47, 399, 20, '2015-09-29 16:00:00', 6, '', '2015-09-08 02:50:46'),
(48, 399, 20, '2015-09-28 16:00:00', 9, 'Yytt', '2015-09-08 02:51:19'),
(49, 399, 20, '2015-09-28 16:00:00', 6, 'aaaf', '2015-09-08 02:55:45'),
(50, 399, 20, '2015-09-30 04:38:54', 10, '', '2015-09-08 03:39:10'),
(51, 399, 14, '2015-09-12 05:10:04', 7, 'Test', '2015-09-11 04:09:03'),
(52, 238, 1, '2015-10-06 11:22:45', 3, '', '2015-10-06 10:23:09'),
(53, 382, 14, '2015-11-27 08:36:03', 8, 'Test just to test the test of this test and test\n', '2015-11-27 07:37:03'),
(54, 42, 8, '2016-01-18 07:00:00', 4, 'Just testing', '2016-01-15 11:25:22'),
(55, 7, 8, '2016-01-18 09:00:40', 8, 'Go here please', '2016-01-15 11:26:18'),
(56, 238, 8, '2016-01-18 03:27:28', 14, 'Please test gps', '2016-01-15 11:28:16'),
(57, 238, 9, '2016-01-19 13:00:00', 11, 'Court 5.2', '2016-01-19 08:02:55'),
(58, 352, 9, '2016-01-21 13:00:00', 12, 'Available after 12', '2016-01-19 08:03:41'),
(59, 383, 24, '2016-01-20 09:16:15', 10, 'Crazy client', '2016-01-20 08:17:23'),
(60, 238, 23, '2016-01-27 02:00:17', 10, 'I need representation for case no. 1234', '2016-01-26 08:46:21'),
(61, 219, 9, '2016-01-28 13:00:00', 11, 'I am available for mentions until 11am', '2016-01-27 23:36:22'),
(62, 238, 26, '2016-01-28 13:00:00', 11, 'I''m available from 10 o''clock if need be', '2016-01-27 23:39:54'),
(63, 238, 9, '2016-01-29 00:40:21', 11, 'Matter of buggalugs in 4.3 - he''s excused, I have $200 - are you able to accept?', '2016-01-27 23:41:19'),
(64, 238, 26, '2016-01-28 00:58:18', 10, 'Test', '2016-01-27 23:59:08'),
(65, 1, 25, '2016-02-03 02:14:59', 3, '', '2016-02-03 01:15:19'),
(66, 238, 8, '2016-02-17 16:00:00', 10, '', '2016-02-11 10:03:05'),
(67, 225, 8, '2016-02-18 02:00:27', 8, '', '2016-02-11 10:04:07'),
(68, 42, 8, '2016-02-18 02:00:37', 8, '', '2016-02-11 10:05:11'),
(69, 29, 23, '2016-02-18 06:00:00', 7, '', '2016-02-11 10:08:42'),
(70, 199, 26, '2016-02-22 13:00:00', 3, '', '2016-02-21 01:43:51');
-- --------------------------------------------------------
--
-- Table structure for table `service_requests`
--
CREATE TABLE IF NOT EXISTS `service_requests` (
`id` bigint(11) unsigned NOT NULL,
`schedule_id` bigint(11) unsigned NOT NULL,
`status` int(11) NOT NULL DEFAULT '0',
`assigned_associate_id` bigint(11) unsigned NOT NULL DEFAULT '0',
`insert_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`update_time` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'
) ENGINE=InnoDB AUTO_INCREMENT=39 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `service_requests`
--
INSERT INTO `service_requests` (`id`, `schedule_id`, `status`, `assigned_associate_id`, `insert_time`, `update_time`) VALUES
(1, 2, 0, 0, '2015-07-27 20:06:50', '2015-07-27 20:06:50'),
(2, 3, 0, 0, '2015-07-27 20:08:56', '2015-07-27 20:08:56'),
(3, 4, 1, 8, '2015-07-27 20:53:38', '2015-07-27 21:24:09'),
(4, 6, 0, 0, '2015-07-28 09:43:16', '2015-07-28 09:43:16'),
(7, 13, 0, 0, '2015-08-01 16:55:00', '2015-08-01 16:55:00'),
(8, 14, 1, 1, '2015-08-03 03:57:45', '2015-08-03 03:59:05'),
(9, 15, 1, 8, '2015-08-03 21:28:14', '2015-08-03 22:15:54'),
(10, 16, 1, 3, '2015-08-04 06:21:33', '2015-08-04 06:22:51'),
(11, 19, 1, 3, '2015-08-04 06:38:53', '2015-08-04 06:43:40'),
(12, 20, 0, 0, '2015-08-04 07:30:37', '2015-08-04 07:30:37'),
(13, 24, 2, 9, '2015-08-04 23:39:25', '2015-08-05 01:46:21'),
(14, 26, 2, 9, '2015-08-10 05:05:05', '2015-08-11 02:26:32'),
(15, 27, 0, 0, '2015-08-10 09:14:45', '2015-08-10 09:14:45'),
(16, 28, 0, 0, '2015-08-10 09:15:25', '2015-08-10 09:15:25'),
(17, 30, 0, 0, '2015-08-14 03:49:26', '2015-08-14 03:49:26'),
(18, 31, 0, 0, '2015-08-17 05:47:31', '2015-08-17 05:47:31'),
(19, 32, 0, 0, '2015-08-18 08:49:55', '2015-08-18 08:49:55'),
(20, 33, 0, 0, '2015-08-18 08:50:52', '2015-08-18 08:50:52'),
(21, 34, 0, 0, '2015-08-18 08:52:59', '2015-08-18 08:52:59'),
(22, 35, 0, 0, '2015-08-18 08:57:32', '2015-08-18 08:57:32'),
(23, 36, 0, 0, '2015-08-18 09:20:08', '2015-08-18 09:20:08'),
(24, 41, 0, 0, '2015-08-27 01:26:34', '2015-08-27 01:26:34'),
(25, 43, 0, 0, '2015-08-27 05:23:51', '2015-08-27 05:23:51'),
(26, 44, 0, 0, '2015-09-07 05:44:56', '2015-09-07 05:44:56'),
(27, 45, 0, 0, '2015-09-07 05:47:50', '2015-09-07 05:47:50'),
(28, 46, 0, 0, '2015-09-08 00:57:02', '2015-09-08 00:57:02'),
(29, 47, 0, 0, '2015-09-08 02:50:46', '2015-09-08 02:50:46'),
(30, 50, 0, 0, '2015-09-08 03:39:11', '2015-09-08 03:39:11'),
(31, 51, 0, 0, '2015-09-11 04:09:03', '2015-09-11 04:09:03'),
(32, 53, 0, 0, '2015-11-27 07:37:04', '2015-11-27 07:37:04'),
(33, 55, 0, 0, '2016-01-15 11:26:18', '2016-01-15 11:26:18'),
(34, 56, 0, 0, '2016-01-15 11:28:16', '2016-01-15 11:28:16'),
(35, 63, 0, 0, '2016-01-27 23:41:19', '2016-01-27 23:41:19'),
(36, 64, 0, 0, '2016-01-27 23:59:08', '2016-01-27 23:59:08'),
(37, 67, 0, 0, '2016-02-11 10:04:07', '2016-02-11 10:04:07'),
(38, 68, 1, 23, '2016-02-11 10:05:11', '2016-02-11 10:07:37');
-- --------------------------------------------------------
--
-- Table structure for table `service_request_assignees`
--
CREATE TABLE IF NOT EXISTS `service_request_assignees` (
`id` bigint(11) unsigned NOT NULL,
`service_request_id` bigint(11) unsigned NOT NULL,
`associate_id` bigint(11) unsigned NOT NULL,
`insert_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB AUTO_INCREMENT=44 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `service_request_assignees`
--
INSERT INTO `service_request_assignees` (`id`, `service_request_id`, `associate_id`, `insert_time`) VALUES
(1, 1, 8, '2015-07-27 20:06:50'),
(2, 2, 8, '2015-07-27 20:08:56'),
(4, 4, 2, '2015-07-28 09:43:16'),
(9, 7, 2, '2015-08-01 16:55:00'),
(10, 7, 11, '2015-08-01 16:55:00'),
(18, 12, 9, '2015-08-04 07:30:37'),
(21, 15, 11, '2015-08-10 09:14:45'),
(23, 17, 12, '2015-08-14 03:49:26'),
(24, 18, 13, '2015-08-17 05:47:31'),
(25, 19, 4, '2015-08-18 08:49:55'),
(26, 20, 11, '2015-08-18 08:50:52'),
(27, 21, 2, '2015-08-18 08:52:59'),
(28, 22, 1, '2015-08-18 08:57:32'),
(29, 23, 16, '2015-08-18 09:20:08'),
(30, 24, 17, '2015-08-27 01:26:34'),
(31, 25, 17, '2015-08-27 05:23:51'),
(32, 26, 14, '2015-09-07 05:44:56'),
(33, 27, 14, '2015-09-07 05:47:50'),
(34, 28, 14, '2015-09-08 00:57:02'),
(35, 29, 17, '2015-09-08 02:50:46'),
(36, 30, 11, '2015-09-08 03:39:11'),
(37, 31, 20, '2015-09-11 04:09:03'),
(38, 32, 12, '2015-11-27 07:37:04'),
(39, 33, 12, '2016-01-15 11:26:18'),
(40, 34, 21, '2016-01-15 11:28:16'),
(41, 35, 26, '2016-01-27 23:41:19'),
(42, 36, 9, '2016-01-27 23:59:08'),
(43, 37, 12, '2016-02-11 10:04:07');
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE IF NOT EXISTS `users` (
`id` int(10) unsigned NOT NULL,
`name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`email` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`password` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`remember_token` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Dumping data for table `users`
--
INSERT INTO `users` (`id`, `name`, `email`, `password`, `remember_token`, `created_at`, `updated_at`) VALUES
(2, 'test user', 'test@test.com', '$2y$10$3OdRju2GfLOMead9.rBYvuNPPSi9yAA1L7BFG81KkK91O/NGMS2zK', NULL, '2016-04-05 04:59:54', '2016-04-05 04:59:54');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `admins`
--
ALTER TABLE `admins`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `associates`
--
ALTER TABLE `associates`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `associate_devices`
--
ALTER TABLE `associate_devices`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `associate_location`
--
ALTER TABLE `associate_location`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `auth`
--
ALTER TABLE `auth`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `courts`
--
ALTER TABLE `courts`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `court_details`
--
ALTER TABLE `court_details`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `favorites`
--
ALTER TABLE `favorites`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `message_inboxes`
--
ALTER TABLE `message_inboxes`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `notifications`
--
ALTER TABLE `notifications`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `oauth_access_tokens`
--
ALTER TABLE `oauth_access_tokens`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `oauth_access_tokens_id_session_id_unique` (`id`,`session_id`),
ADD KEY `oauth_access_tokens_session_id_index` (`session_id`);
--
-- Indexes for table `oauth_access_token_scopes`
--
ALTER TABLE `oauth_access_token_scopes`
ADD PRIMARY KEY (`id`),
ADD KEY `oauth_access_token_scopes_access_token_id_index` (`access_token_id`),
ADD KEY `oauth_access_token_scopes_scope_id_index` (`scope_id`);
--
-- Indexes for table `oauth_auth_codes`
--
ALTER TABLE `oauth_auth_codes`
ADD PRIMARY KEY (`id`),
ADD KEY `oauth_auth_codes_session_id_index` (`session_id`);
--
-- Indexes for table `oauth_auth_code_scopes`
--
ALTER TABLE `oauth_auth_code_scopes`
ADD PRIMARY KEY (`id`),
ADD KEY `oauth_auth_code_scopes_auth_code_id_index` (`auth_code_id`),
ADD KEY `oauth_auth_code_scopes_scope_id_index` (`scope_id`);
--
-- Indexes for table `oauth_clients`
--
ALTER TABLE `oauth_clients`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `oauth_clients_id_secret_unique` (`id`,`secret`);
--
-- Indexes for table `oauth_client_endpoints`
--
ALTER TABLE `oauth_client_endpoints`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `oauth_client_endpoints_client_id_redirect_uri_unique` (`client_id`,`redirect_uri`);
--
-- Indexes for table `oauth_client_grants`
--
ALTER TABLE `oauth_client_grants`
ADD PRIMARY KEY (`id`),
ADD KEY `oauth_client_grants_client_id_index` (`client_id`),
ADD KEY `oauth_client_grants_grant_id_index` (`grant_id`);
--
-- Indexes for table `oauth_client_scopes`
--
ALTER TABLE `oauth_client_scopes`
ADD PRIMARY KEY (`id`),
ADD KEY `oauth_client_scopes_client_id_index` (`client_id`),
ADD KEY `oauth_client_scopes_scope_id_index` (`scope_id`);
--
-- Indexes for table `oauth_grants`
--
ALTER TABLE `oauth_grants`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `oauth_grant_scopes`
--
ALTER TABLE `oauth_grant_scopes`
ADD PRIMARY KEY (`id`),
ADD KEY `oauth_grant_scopes_grant_id_index` (`grant_id`),
ADD KEY `oauth_grant_scopes_scope_id_index` (`scope_id`);
--
-- Indexes for table `oauth_refresh_tokens`
--
ALTER TABLE `oauth_refresh_tokens`
ADD PRIMARY KEY (`access_token_id`),
ADD UNIQUE KEY `oauth_refresh_tokens_id_unique` (`id`);
--
-- Indexes for table `oauth_scopes`
--
ALTER TABLE `oauth_scopes`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `oauth_sessions`
--
ALTER TABLE `oauth_sessions`
ADD PRIMARY KEY (`id`),
ADD KEY `oauth_sessions_client_id_owner_type_owner_id_index` (`client_id`,`owner_type`,`owner_id`);
--
-- Indexes for table `oauth_session_scopes`
--
ALTER TABLE `oauth_session_scopes`
ADD PRIMARY KEY (`id`),
ADD KEY `oauth_session_scopes_session_id_index` (`session_id`),
ADD KEY `oauth_session_scopes_scope_id_index` (`scope_id`);
--
-- Indexes for table `password_resets`
--
ALTER TABLE `password_resets`
ADD KEY `password_resets_email_index` (`email`),
ADD KEY `password_resets_token_index` (`token`);
--
-- Indexes for table `request_types`
--
ALTER TABLE `request_types`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `schedules`
--
ALTER TABLE `schedules`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `service_requests`
--
ALTER TABLE `service_requests`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `service_request_assignees`
--
ALTER TABLE `service_request_assignees`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `users_email_unique` (`email`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `admins`
--
ALTER TABLE `admins`
MODIFY `id` bigint(11) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT for table `associates`
--
ALTER TABLE `associates`
MODIFY `id` bigint(11) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=36;
--
-- AUTO_INCREMENT for table `associate_devices`
--
ALTER TABLE `associate_devices`
MODIFY `id` bigint(11) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=27;
--
-- AUTO_INCREMENT for table `associate_location`
--
ALTER TABLE `associate_location`
MODIFY `id` bigint(11) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=66;
--
-- AUTO_INCREMENT for table `auth`
--
ALTER TABLE `auth`
MODIFY `id` bigint(11) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `courts`
--
ALTER TABLE `courts`
MODIFY `id` bigint(11) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=175;
--
-- AUTO_INCREMENT for table `court_details`
--
ALTER TABLE `court_details`
MODIFY `id` bigint(11) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=400;
--
-- AUTO_INCREMENT for table `favorites`
--
ALTER TABLE `favorites`
MODIFY `id` bigint(11) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=28;
--
-- AUTO_INCREMENT for table `message_inboxes`
--
ALTER TABLE `message_inboxes`
MODIFY `id` bigint(11) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=16;
--
-- AUTO_INCREMENT for table `notifications`
--
ALTER TABLE `notifications`
MODIFY `id` bigint(11) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=112;
--
-- AUTO_INCREMENT for table `oauth_access_token_scopes`
--
ALTER TABLE `oauth_access_token_scopes`
MODIFY `id` int(10) unsigned NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `oauth_auth_code_scopes`
--
ALTER TABLE `oauth_auth_code_scopes`
MODIFY `id` int(10) unsigned NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `oauth_client_endpoints`
--
ALTER TABLE `oauth_client_endpoints`
MODIFY `id` int(10) unsigned NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `oauth_client_grants`
--
ALTER TABLE `oauth_client_grants`
MODIFY `id` int(10) unsigned NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `oauth_client_scopes`
--
ALTER TABLE `oauth_client_scopes`
MODIFY `id` int(10) unsigned NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `oauth_grant_scopes`
--
ALTER TABLE `oauth_grant_scopes`
MODIFY `id` int(10) unsigned NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `oauth_sessions`
--
ALTER TABLE `oauth_sessions`
MODIFY `id` int(10) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=11;
--
-- AUTO_INCREMENT for table `oauth_session_scopes`
--
ALTER TABLE `oauth_session_scopes`
MODIFY `id` int(10) unsigned NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `request_types`
--
ALTER TABLE `request_types`
MODIFY `id` bigint(11) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=18;
--
-- AUTO_INCREMENT for table `schedules`
--
ALTER TABLE `schedules`
MODIFY `id` bigint(11) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=71;
--
-- AUTO_INCREMENT for table `service_requests`
--
ALTER TABLE `service_requests`
MODIFY `id` bigint(11) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=39;
--
-- AUTO_INCREMENT for table `service_request_assignees`
--
ALTER TABLE `service_request_assignees`
MODIFY `id` bigint(11) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=44;
--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
MODIFY `id` int(10) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=3;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `oauth_access_tokens`
--
ALTER TABLE `oauth_access_tokens`
ADD CONSTRAINT `oauth_access_tokens_session_id_foreign` FOREIGN KEY (`session_id`) REFERENCES `oauth_sessions` (`id`) ON DELETE CASCADE;
--
-- Constraints for table `oauth_access_token_scopes`
--
ALTER TABLE `oauth_access_token_scopes`
ADD CONSTRAINT `oauth_access_token_scopes_access_token_id_foreign` FOREIGN KEY (`access_token_id`) REFERENCES `oauth_access_tokens` (`id`) ON DELETE CASCADE,
ADD CONSTRAINT `oauth_access_token_scopes_scope_id_foreign` FOREIGN KEY (`scope_id`) REFERENCES `oauth_scopes` (`id`) ON DELETE CASCADE;
--
-- Constraints for table `oauth_auth_codes`
--
ALTER TABLE `oauth_auth_codes`
ADD CONSTRAINT `oauth_auth_codes_session_id_foreign` FOREIGN KEY (`session_id`) REFERENCES `oauth_sessions` (`id`) ON DELETE CASCADE;
--
-- Constraints for table `oauth_auth_code_scopes`
--
ALTER TABLE `oauth_auth_code_scopes`
ADD CONSTRAINT `oauth_auth_code_scopes_auth_code_id_foreign` FOREIGN KEY (`auth_code_id`) REFERENCES `oauth_auth_codes` (`id`) ON DELETE CASCADE,
ADD CONSTRAINT `oauth_auth_code_scopes_scope_id_foreign` FOREIGN KEY (`scope_id`) REFERENCES `oauth_scopes` (`id`) ON DELETE CASCADE;
--
-- Constraints for table `oauth_client_endpoints`
--
ALTER TABLE `oauth_client_endpoints`
ADD CONSTRAINT `oauth_client_endpoints_client_id_foreign` FOREIGN KEY (`client_id`) REFERENCES `oauth_clients` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Constraints for table `oauth_client_grants`
--
ALTER TABLE `oauth_client_grants`
ADD CONSTRAINT `oauth_client_grants_client_id_foreign` FOREIGN KEY (`client_id`) REFERENCES `oauth_clients` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION,
ADD CONSTRAINT `oauth_client_grants_grant_id_foreign` FOREIGN KEY (`grant_id`) REFERENCES `oauth_grants` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION;
--
-- Constraints for table `oauth_client_scopes`
--
ALTER TABLE `oauth_client_scopes`
ADD CONSTRAINT `oauth_client_scopes_client_id_foreign` FOREIGN KEY (`client_id`) REFERENCES `oauth_clients` (`id`) ON DELETE CASCADE,
ADD CONSTRAINT `oauth_client_scopes_scope_id_foreign` FOREIGN KEY (`scope_id`) REFERENCES `oauth_scopes` (`id`) ON DELETE CASCADE;
--
-- Constraints for table `oauth_grant_scopes`
--
ALTER TABLE `oauth_grant_scopes`
ADD CONSTRAINT `oauth_grant_scopes_grant_id_foreign` FOREIGN KEY (`grant_id`) REFERENCES `oauth_grants` (`id`) ON DELETE CASCADE,
ADD CONSTRAINT `oauth_grant_scopes_scope_id_foreign` FOREIGN KEY (`scope_id`) REFERENCES `oauth_scopes` (`id`) ON DELETE CASCADE;
--
-- Constraints for table `oauth_refresh_tokens`
--
ALTER TABLE `oauth_refresh_tokens`
ADD CONSTRAINT `oauth_refresh_tokens_access_token_id_foreign` FOREIGN KEY (`access_token_id`) REFERENCES `oauth_access_tokens` (`id`) ON DELETE CASCADE;
--
-- Constraints for table `oauth_sessions`
--
ALTER TABLE `oauth_sessions`
ADD CONSTRAINT `oauth_sessions_client_id_foreign` FOREIGN KEY (`client_id`) REFERENCES `oauth_clients` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Constraints for table `oauth_session_scopes`
--
ALTER TABLE `oauth_session_scopes`
ADD CONSTRAINT `oauth_session_scopes_scope_id_foreign` FOREIGN KEY (`scope_id`) REFERENCES `oauth_scopes` (`id`) ON DELETE CASCADE,
ADD CONSTRAINT `oauth_session_scopes_session_id_foreign` FOREIGN KEY (`session_id`) REFERENCES `oauth_sessions` (`id`) ON DELETE CASCADE;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
USE ProjetRJ;
DROP PROCEDURE IF EXISTS ps_creer_abonnement;
DELIMITER #
CREATE PROCEDURE ps_creer_abonnement (IN p_pseudonyme_demandeur VARCHAR(40), IN p_pseudonyme_influenceur VARCHAR(40))
BEGIN
DECLARE l_id_influenceur INT;
DECLARE l_id_demandeur INT;
DECLARE l_relation_existante INT;
SET @l_id_influenceur = (SELECT id_utilisateur FROM t_utilisateur WHERE pseudonyme = p_pseudonyme_influenceur AND pouvoir = 'public');
SET @l_id_demandeur = (SELECT id_utilisateur FROM t_utilisateur WHERE pseudonyme = p_pseudonyme_demandeur);
SET @l_relation_existante = (SELECT COUNT(*) FROM t_utilisateur_relation WHERE id_utilisateur_demandeur = l_id_demandeur AND id_utilisateur_repondant = l_id_influenceur);
IF (@l_id_influenceur IS NOT NULL AND @l_id_demandeur IS NOT NULL AND @l_relation_existante = 0 AND @l_id_demandeur <> @l_id_influenceur) THEN
INSERT INTO t_utilisateur_relation (id_utilisateur_demandeur, id_utilisateur_repondant, relation)
VALUES (@l_id_demandeur, @l_id_influenceur, 'ami');
END IF;
END#
DELIMITER ;
|
-- #10 projects, 20 users, 30 pledges
INSERT INTO projects(title, category, funding_goal, start_date, end_date)
VALUES("Space Camp", "Science", 10000, "March 31, 2020", "April 14, 2020");
INSERT INTO projects(title, category, funding_goal, start_date, end_date)
VALUES("Community Clean-up", "Community", 12000, "February 20, 2020", "March 30, 2020");
INSERT INTO projects(title, category, funding_goal, start_date, end_date)
VALUES("Free food", "Misc.", 600, "February 27, 2020", "March 14, 2020");
INSERT INTO projects(title, category, funding_goal, start_date, end_date)
VALUES("Space Camp", "Science", 10000, "March 31, 2020", "April 14, 2020");
INSERT INTO projects(title, category, funding_goal, start_date, end_date)
VALUES("Community Clean-up", "Community", 12000, "February 20, 2020", "March 30, 2020");
INSERT INTO projects(title, category, funding_goal, start_date, end_date)
VALUES("Free food", "Misc.", 600, "February 27, 2020", "March 14, 2020");
INSERT INTO projects(title, category, funding_goal, start_date, end_date)
VALUES("Space Camp", "Science", 10000, "March 31, 2020", "April 14, 2020");
INSERT INTO projects(title, category, funding_goal, start_date, end_date)
VALUES("Community Clean-up", "Community", 12000, "February 20, 2020", "March 30, 2020");
INSERT INTO projects(title, category, funding_goal, start_date, end_date)
VALUES("Free food", "Misc.", 600, "February 27, 2020", "March 14, 2020");
INSERT INTO projects(title, category, funding_goal, start_date, end_date)
VALUES("Free food", "Misc.", 600, "February 27, 2020", "March 14, 2020");
INSERT INTO users(name, age)
VALUES("John Doe", 33);
INSERT INTO users(name, age)
VALUES("Jane Doe", 23);
INSERT INTO users(name, age)
VALUES("William Johnson", 47);
INSERT INTO users(name, age)
VALUES("Bill Nye", 52);
INSERT INTO users(name, age)
VALUES("John Doe", 33);
INSERT INTO users(name, age)
VALUES("Jane Doe", 23);
INSERT INTO users(name, age)
VALUES("William Johnson", 47);
INSERT INTO users(name, age)
VALUES("Bill Nye", 52);
INSERT INTO users(name, age)
VALUES("John Doe", 33);
INSERT INTO users(name, age)
VALUES("Jane Doe", 23);
INSERT INTO users(name, age)
VALUES("William Johnson", 47);
INSERT INTO users(name, age)
VALUES("Bill Nye", 52);
INSERT INTO users(name, age)
VALUES("John Doe", 33);
INSERT INTO users(name, age)
VALUES("Jane Doe", 23);
INSERT INTO users(name, age)
VALUES("William Johnson", 47);
INSERT INTO users(name, age)
VALUES("Bill Nye", 52);
INSERT INTO users(name, age)
VALUES("John Doe", 33);
INSERT INTO users(name, age)
VALUES("Jane Doe", 23);
INSERT INTO users(name, age)
VALUES("William Johnson", 47);
INSERT INTO users(name, age)
VALUES("Bill Nye", 52);
INSERT INTO pledges(amount, user_id, project_id)
VALUES(100, 14, 9);
INSERT INTO pledges(amount, user_id, project_id)
VALUES(200, 11, 4);
INSERT INTO pledges(amount, user_id, project_id)
VALUES(500, 10, 4);
INSERT INTO pledges(amount, user_id, project_id)
VALUES(10, 20, 7);
INSERT INTO pledges(amount, user_id, project_id)
VALUES(1, 1, 1);
INSERT INTO pledges(amount, user_id, project_id)
VALUES(2, 2, 2);
INSERT INTO pledges(amount, user_id, project_id)
VALUES(3, 3, 3);
INSERT INTO pledges(amount, user_id, project_id)
VALUES(4, 4, 4);
INSERT INTO pledges(amount, user_id, project_id)
VALUES(5, 5, 5);
INSERT INTO pledges(amount, user_id, project_id)
VALUES(70, 7, 7);
INSERT INTO pledges(amount, user_id, project_id)
VALUES(100, 14, 9);
INSERT INTO pledges(amount, user_id, project_id)
VALUES(200, 11, 4);
INSERT INTO pledges(amount, user_id, project_id)
VALUES(500, 10, 4);
INSERT INTO pledges(amount, user_id, project_id)
VALUES(10, 20, 7);
INSERT INTO pledges(amount, user_id, project_id)
VALUES(1, 1, 1);
INSERT INTO pledges(amount, user_id, project_id)
VALUES(2, 2, 2);
INSERT INTO pledges(amount, user_id, project_id)
VALUES(3, 3, 3);
INSERT INTO pledges(amount, user_id, project_id)
VALUES(4, 4, 4);
INSERT INTO pledges(amount, user_id, project_id)
VALUES(5, 5, 5);
INSERT INTO pledges(amount, user_id, project_id)
VALUES(70, 7, 7);
INSERT INTO pledges(amount, user_id, project_id)
VALUES(100, 14, 9);
INSERT INTO pledges(amount, user_id, project_id)
VALUES(200, 11, 4);
INSERT INTO pledges(amount, user_id, project_id)
VALUES(500, 10, 4);
INSERT INTO pledges(amount, user_id, project_id)
VALUES(10, 20, 7);
INSERT INTO pledges(amount, user_id, project_id)
VALUES(1, 1, 1);
INSERT INTO pledges(amount, user_id, project_id)
VALUES(2, 2, 2);
INSERT INTO pledges(amount, user_id, project_id)
VALUES(3, 3, 3);
INSERT INTO pledges(amount, user_id, project_id)
VALUES(4, 4, 4);
INSERT INTO pledges(amount, user_id, project_id)
VALUES(5, 5, 5);
INSERT INTO pledges(amount, user_id, project_id)
VALUES(70, 7, 7);
|
-- Convert Python's datetime.weekday() to names
-- Run with "psql -U <user> <database> -1 -f wdays.sql"
CREATE TABLE weekdays (
num TEXT
, weekday TEXT
);
CREATE INDEX weekdays_num ON weekdays(num);
INSERT INTO weekdays
(num, weekday)
VALUES
('0', 'Monday')
, ('1', 'Tuesday')
, ('2', 'Wednesday')
, ('3', 'Thursday')
, ('4', 'Friday')
, ('5', 'Saturday')
, ('6', 'Sunday')
;
UPDATE facts
SET day = weekdays.weekday
FROM weekdays
WHERE day = weekdays.num
;
DROP TABLE weekdays CASCADE;
|
SELECT d.year::int,
round(sum(lsm.value), 2) AS value
FROM authorship a
JOIN document d ON a.document = d.id
JOIN latest_source_metric lsm ON d.source = lsm.source
WHERE a."researchEntity" = $1
AND lsm.name = $2
AND d.documenttype <> ALL ($3 :: INT[])
GROUP BY d.year |
--创建数据库 stusys;
create dataBase stusys character set utf8;
--切换数据库到 stusys
use stusys
--创建班级信息表
create table classInfo(
cid int primary key auto_increment, --班级编号 主键列 自动增长
cname varchar(100) not null unique, --班级名称 唯一 不能为空
status int --班级状态
);
--修改自增的起始值
alter table classInfo auto_increment=1001;
--创建学生信息表
create table stuInfo(
sid int primary key auto_increment, --学号
sname varchar(100) not null, --姓名
cid int, --所在班级编号
sex varchar(4), --性别
age int, --年龄
pwd varchar(100), --密码
tel varchar(15) --联系方式
);
--修改学号的起始值
alter table stuInfo auto_increment=10001;
--添加班级的初始数据 注意:mysql中自增列用0代替
insert into classInfo values(0,'YC24',1);
insert into classInfo values(0,'YC23',1);
insert into classInfo values(0,'YC25',1);
--添加学生的初始数据
insert into stuInfo values(0,'纯纯',1001,'女',18,'aaaa','15074717797');
--在cmd里面停止数据库
net stop mysql
--在cmd里面启动数据库
net start mysql
|
SELECT *
FROM orders
WHERE date = NOW()
ORDER BY number; |
USE SENAI_HROADS_MANHA
-- 06. Selecionar todos os personagens;
SELECT * FROM Personagens
-- 07. Selecionar todos as classes;
SELECT * FROM Classes
-- 08. Selecionar somente o nome das classes;
SELECT Nome FROM Classes;
-- 09. Selecionar todas as habilidades;
SELECT * FROM Habilidades
-- 10. Realizar a contagem de quantas habilidades estão cadastradas;
SELECT COUNT (IdHabilidade) FROM Habilidades
-- 11. Selecionar somente os id’s das habilidades classificando-os por ordem crescente;
SELECT IdHabilidade FROM Habilidades ORDER BY IdHabilidade
-- 12. Selecionar todos os tipos de habilidades;
SELECT * FROM TiposDeHabilidades
-- 13. Selecionar todas as habilidades e a quais tipos de habilidades elas fazem parte;
SELECT Habilidades.Nome AS 'Habilidade', TiposDeHabilidades.Nome AS 'Tipo Habilidade' FROM Habilidades
INNER JOIN TiposDeHabilidades
ON Habilidades.IdTipoDeHabilidade = TiposDeHabilidades.IdTipoHabilidade;
-- 14. Selecionar todos os personagens e suas respectivas classes;
SELECT Personagens.Nome AS 'Personagem', Classes.Nome AS 'Nome Classe' FROM Personagens
INNER JOIN Classes
ON Classes.IdClasse = Personagens.IdClasse;
-- 15. Selecionar todos os personagens e as classes (mesmo que elas não tenham correspondência em personagens);
SELECT Personagens.Nome AS 'Personagem', Classes.Nome AS 'Nome Classe' FROM Personagens
FULL OUTER JOIN Classes
ON Personagens.IdClasse = Classes.IdClasse;
-- 16. Selecionar todas as classes e suas respectivas habilidades;
SELECT Classes.Nome, Habilidades.Nome FROM ClassesHabilidades
LEFT JOIN Classes
ON ClassesHabilidades.IdClasse = Classes.IdClasse
LEFT JOIN Habilidades
ON ClassesHabilidades.IdHabilidade = Habilidades.IdHabilidade;
-- 17. Selecionar todas as habilidades e suas classes (somente as que possuem correspondência);
SELECT Habilidades.Nome as 'Nome da Habilidade', Classes.Nome as 'Nome da Classe' FROM ClassesHabilidades
RIGHT JOIN Classes
ON ClassesHabilidades.IdClasse = Classes.IdClasse
RIGHT JOIN Habilidades
ON ClassesHabilidades.IdHabilidade = Habilidades.IdHabilidade;
-- 18. Selecionar todas as habilidades e suas classes (mesmo que elas não tenham correspondência).
SELECT Habilidades.Nome as 'Nome da Habilidade', Classes.Nome as 'Nome da Classe' FROM ClassesHabilidades
FULL OUTER JOIN Classes
ON ClassesHabilidades.IdClasse = Classes.IdClasse
FULL OUTER JOIN Habilidades
ON ClassesHabilidades.IdHabilidade = Habilidades.IdHabilidade; |
DROP TABLE IF EXISTS events;
CREATE TABLE events (
event_id serial NOT NULL,
send_to int default 0,
send_from int default 0,
message varchar(255) NOT NULL,
unread int NOT NULL default 1,
date timestamp without time zone NOT NULL default now()
);
ALTER TABLE events OWNER TO developers;
GRANT ALL ON TABLE events TO developers;
|
# Host: 192.168.82.27 (Version: 5.6.29-log)
# Date: 2017-09-19 16:14:55
# Generator: MySQL-Front 5.3 (Build 4.214)
/*!40101 SET NAMES utf8 */;
#
# Structure for table "jg_customer"
#
DROP TABLE IF EXISTS `jg_customer`;
CREATE TABLE `jg_customer` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL DEFAULT '',
`mobile` varchar(15) NOT NULL DEFAULT '',
`qq` varchar(15) NOT NULL DEFAULT '',
`addr` varchar(255) NOT NULL DEFAULT '',
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`isDel` tinyint(3) unsigned NOT NULL DEFAULT '0',
`desc` varchar(5000) NOT NULL DEFAULT '',
`adminId` int(11) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;
#
# Data for table "jg_customer"
#
#
# Structure for table "jg_user"
#
DROP TABLE IF EXISTS `jg_user`;
CREATE TABLE `jg_user` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL DEFAULT '',
`password` varchar(255) NOT NULL DEFAULT '',
`roleId` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '1:超级管理员,2普通',
`email` varchar(255) NOT NULL DEFAULT '',
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`isDel` tinyint(3) unsigned NOT NULL DEFAULT '0',
`realName` varchar(255) NOT NULL DEFAULT '',
`remember_token` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;
#
# Data for table "jg_user"
#
#
# Structure for table "jg_user_mods"
#
DROP TABLE IF EXISTS `jg_user_mods`;
CREATE TABLE `jg_user_mods` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`roleId` int(11) unsigned NOT NULL DEFAULT '0',
`mid` int(11) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
#
# Data for table "jg_user_mods"
#
|
SELECT
prod_detalle,
MAX(s1.stoc_cantidad) AS stock_maximo
FROM
Producto
JOIN STOCK s1 ON prod_codigo = s1.stoc_producto
GROUP BY
prod_detalle,
prod_codigo
HAVING
0 < ALL(
SELECT
s2.stoc_cantidad
FROM
STOCK s2
WHERE
s2.stoc_producto = prod_codigo
)
AND COUNT(*) = (
SELECT
COUNT(*)
FROM
DEPOSITO
GROUP BY
depo_codigo
); |
-- TRUNCATE planeten;
SELECT * FROM planets;
CREATE TABLE Zonnestelsel(
naam varchar(20),
diameter INT,
afstand_tot_de_zon float,
massa_tov_de_aarde float
);
INSERT INTO zonnestelsel VALUES(
"Neptunus","49572","4498252900","17",""
);
UPDATE zonnestelsel
SET bezoek_datum = "tess";
ALTER TABLE zonnestelsel ADD primary key (naam,diameter,afstand_tot_de_zon,massa_tov_de_aarde);
DESC zonnestelsel;
ALTER TABLE zonnestelsel ADD (bezoek_datum datetime);
INSERT INTO bezoek_datum VALUES('1969-07-20');
ALTER TABLE zonnestelsel ADD (bezoek_datum date) ;
ALTER TABLE zonnestelsel Drop column bezoek_datum;
UPDATE `sterrenstelsel`.`Zonnestelsel` SET `bezoek_datum` = '1969-07-20' WHERE (`naam` = 'Aarde');
ALTER TABLE planets rename to planeten; |
USE ecommerce;
DROP PROCEDURE IF EXISTS countSuscriptionPerCategory;
DELIMITER $$
CREATE PROCEDURE countSuscriptionPerCategory()
BEGIN
SELECT
COUNT(SUSCRIPTION.Id_Suscription ) AS total, CATEGORY.Name AS Name
FROM
SUSCRIPTION
JOIN
CATEGORY ON SUSCRIPTION.Id_Category_FK = CATEGORY.Id
JOIN
USER ON SUSCRIPTION.Id_User_FK = USER.Id
WHERE
CATEGORY.Status = 1 AND
USER.Id_State = 1
GROUP BY
CATEGORY.Name
;
END $$
DELIMITER ;
|
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
* Author: Jianmu Huang
* Created: 26/05/2020
*/
DROP TABLE DEVICE;
CREATE TABLE DEVICE
(
"ID" INT not null primary key
GENERATED ALWAYS AS IDENTITY
(START WITH 1, INCREMENT BY 1),
"NAME" VARCHAR(500),
"TYPE" VARCHAR(500),
"PRICE" DOUBLE,
"QUANTITY" INTEGER
);
INSERT INTO DEVICE ("NAME", "TYPE", "PRICE", "QUANTITY") VALUES ('Canon 800D Camera', 'Photography', 2000.0, 20),
('Samsung Galaxy S10', 'Mobile', 1399.0, 40);
|
use test;
create table open_projects(
id_project int (10) AUTO_INCREMENT,
name varchar(20) NOT NULL,
theme varchar(20) NOT NULL,
about varchar(350) NOT NULL,
PRIMARY KEY (id_project) ); |
USE movie_sc;
INSERT INTO movies VALUES ('1','John Lasseter','Toy Story',1,20);
INSERT INTO movies VALUES ('2','Joe Johnston','Jumanji',2,20);
INSERT INTO movies VALUES ('3','Howard Deutch','Grumpier Old Men',3,20);
INSERT INTO movies VALUES ('4','Forest Whitaker','Waiting to Exhale',3,20);
INSERT INTO movies VALUES ('5','Charles Shyer','Father of the Bride Part II',3,20);
INSERT INTO movies VALUES ('6','Michael Mann','Heat',4,20);
INSERT INTO movies VALUES ('7','Sydney Pollack','Sabrina',3,20);
INSERT INTO movies VALUES ('8','Peter Hewitt','Tom and Huck',2,20);
INSERT INTO movies VALUES ('9','Peter Hyams','Sudden Death',4,20);
INSERT INTO movies VALUES ('10','Martin Campbell','GoldenEye',4,20);
INSERT INTO movies VALUES ('11','Rob Reiner','The American President',3,20);
INSERT INTO movies VALUES ('12','Mel Brooks','Dracula: Dead and Loving It',3,20);
INSERT INTO movies VALUES ('13','Simon Wells','Balto',1,20);
INSERT INTO movies VALUES ('14','Oliver Stone','Nixon',5,20);
INSERT INTO movies VALUES ('15','Renny Harlin','Cutthroat Island',3,20);
INSERT INTO movies VALUES ('16','Martin Scorsese','Casino',5,20);
INSERT INTO movies VALUES ('17','Ang Lee','Sense and Sensibility',5,20);
INSERT INTO movies VALUES ('18','Roald Dahl','Four Rooms',6,20);
INSERT INTO movies VALUES ('19','Steve Oedekerk','Ace Ventura: When Nature Calls',3,20);
INSERT INTO movies VALUES ('20','Joseph Ruben','Money Train',4,20);
INSERT INTO movies VALUES ('21','Barry Sonnenfeld','Get Shorty',4,20);
INSERT INTO movies VALUES ('22','Jon Amiel','Copycat',5,20);
INSERT INTO movies VALUES ('23','Richard Donner','Assassins',6,20);
INSERT INTO movies VALUES ('24','Victor Salva','Powder',5,20);
INSERT INTO movies VALUES ('25','Mike Figgis','Leaving Las Vegas',5,20);
INSERT INTO movies VALUES ('26',' Oliver Parker','Othello',6,20);
INSERT INTO movies VALUES ('27','Lesli Linka Glatter','Now and Then',5,20);
INSERT INTO categories VALUES (1,'Animation');
INSERT INTO categories VALUES (2,'Adventure');
INSERT INTO categories VALUES (3,'Comedy');
INSERT INTO categories VALUES (4,'Action');
INSERT INTO categories VALUES (5,'Drama');
INSERT INTO categories VALUES (6,'Thriller');
INSERT INTO admin VALUES ('admin', sha1('admin')); |
-- https://www.hackerrank.com/challenges/weather-observation-station-17
SELECT CAST(SUM(LONG_W) AS NUMERIC(9,4))
FROM STATION
WHERE LAT_N = (SELECT MIN(LAT_N) FROM STATION WHERE LAT_N > 38.7780) |
with clean_data as (
select *
from {{ ref('clean_data') }}
)
select complaint_type,
count("*") as nr_complaints
from clean_data
group by 1
order by 2 desc
limit 5 |
SET ECHO ON
rem
rem Towson University
rem Subject: Database Management System(COSC 578)
rem
rem Description: Select name and relationship of all department
rem managers who have dependent
SET HEADSEP!
TTITLE 'Computer Stock Inventory Database System'
BTITLE '...report prepared by Mirza Ashek Ahmed.'
SELECT EMP_FNAME,EMP_LNAME,RELATIONSHIP
FROM EMPLOYEE,DEPENDENT
WHERE EMP_SSN=DSSN AND DESIGNATION='MANAGER';
SET ECHO OFF
|
use master
use Lab4
--1--
select FACULTY.FACULTY, PULPIT.PULPIT_NAME, PROFESSION.PROFESSION_NAME FROM
FACULTY, PULPIT, PROFESSION
Where FACULTY.FACULTY = PULPIT.FACULTY and
PROFESSION.PROFESSION_NAME in (select PROFESSION_NAME from PROFESSION
where (PROFESSION_NAME like '%технология%') or (PROFESSION_NAME like '%технологии%'))
--2,3--
select FACULTY.FACULTY, PULPIT.PULPIT_NAME, PROFESSION.PROFESSION_NAME FROM
FACULTY inner join PULPIT on FACULTY.FACULTY = PULPIT.FACULTY
inner join PROFESSION
on PROFESSION.FACULTY = PULPIT.FACULTY
where (PROFESSION_NAME like '%технология%') or (PROFESSION_NAME like '%технологии%')
--4--
select AUDITORIUM_TYPE, AUDITORIUM_CAPACITY from AUDITORIUM one
where one.AUDITORIUM_TYPE = (select top(1) AUDITORIUM_TYPE from AUDITORIUM two
where two.AUDITORIUM_TYPE = one.AUDITORIUM_TYPE
order by AUDITORIUM_CAPACITY desc)
--5--
select FACULTY_NAME from FACULTY, PULPIT
where not exists (select*from FACULTY
where FACULTY.FACULTY = PULPIT.FACULTY)
--6--
select top 1
(select avg(NOTE) from PROGRESS
where SUBJECT like 'ОАиП') [Прога],
(select avg(NOTE) from PROGRESS
where SUBJECT like 'БД') [Базы данных],
(select avg(NOTE) from PROGRESS
where SUBJECT like 'СУБД') [СУБД]
--7--
select SUBJECT, NOTE from PROGRESS
where NOTE >=all(select NOTE from PROGRESS
where SUBJECT like '%ОАиП%')
--8--
select SUBJECT, NOTE from PROGRESS
where NOTE >any (select NOTE from PROGRESS
where PROGRESS.SUBJECT like '%ОАиП%') |
/*
Warnings:
- Added the required column `comentario` to the `productoDeVenta` table without a default value. This is not possible if the table is not empty.
- Added the required column `fechaFabricado` to the `venta` table without a default value. This is not possible if the table is not empty.
- Added the required column `fechaEntregado` to the `venta` table without a default value. This is not possible if the table is not empty.
- Added the required column `estado` to the `venta` table without a default value. This is not possible if the table is not empty.
- Added the required column `comentario` to the `venta` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "productoDeVenta" ADD COLUMN "comentario" VARCHAR(127) NOT NULL;
-- AlterTable
ALTER TABLE "venta" ADD COLUMN "fechaFabricado" TIMESTAMP(3) NOT NULL,
ADD COLUMN "fechaEntregado" TIMESTAMP(3) NOT NULL,
ADD COLUMN "estado" INTEGER NOT NULL,
ADD COLUMN "comentario" VARCHAR(255) NOT NULL;
-- CreateTable
CREATE TABLE "entrega" (
"id" BIGSERIAL NOT NULL,
"idVenta" BIGINT NOT NULL,
"fechaEntrega" TIMESTAMP(3) NOT NULL,
"horaMin" TIMESTAMP(3) NOT NULL,
"horaMax" TIMESTAMP(3) NOT NULL,
PRIMARY KEY ("id")
);
-- AddForeignKey
ALTER TABLE "entrega" ADD FOREIGN KEY ("idVenta") REFERENCES "venta"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
SELECT tipo FROM pois.poi;
SELECT poi.id FROM pois.poi where baja IS null ; |
-- ABASTAMENT
CREATE OR REPLACE VIEW GW_MIGRA_NETAQUA.EXT_ADDRESS AS
SELECT ROW_NUMBER() OVER (ORDER BY EXPL_ID, STREETAXIS_ID, ORDRE ) ID,
T.MUNI_ID, T.POSTCODE, T.STREETAXIS_ID, T.POSTNUMBER, PLOT_ID, T.THE_GEOM, T.EXPL_ID
FROM (
SELECT 1 MUNI_ID,
NULL POSTCODE,
CAST(CODI_CARRER AS VARCHAR(15)) STREETAXIS_ID,
NUMERO POSTNUMBER,
TO_NUMBER( regexp_replace(NUMERO, '[^0-9]', '') ) ORDRE,
NULL PLOT_ID,
MDSYS.SDO_GEOMETRY(2001,25831,MDSYS.SDO_POINT_TYPE( X_COORD, Y_COORD, null), null, null) THE_GEOM,
1 EXPL_ID
FROM NA_MATARO.CAT_T_NUM_POSTALS
) T;
-- CLAVEGUERAM
CREATE OR REPLACE VIEW GW_MIGRA_NETSANEA.EXT_ADDRESS AS
SELECT ROW_NUMBER() OVER (ORDER BY EXPL_ID, STREETAXIS_ID, ORDRE ) ID,
T.MUNI_ID, T.POSTCODE, T.STREETAXIS_ID, T.POSTNUMBER, PLOT_ID, T.THE_GEOM, T.EXPL_ID
FROM (
SELECT 1 MUNI_ID,
NULL POSTCODE,
CAST(CODI_CARRER AS VARCHAR(15)) STREETAXIS_ID,
NUMERO POSTNUMBER,
TO_NUMBER( regexp_replace(NUMERO, '[^0-9]', '') ) ORDRE,
NULL PLOT_ID,
MDSYS.SDO_GEOMETRY(2001,25831,MDSYS.SDO_POINT_TYPE( X_COORD, Y_COORD, null), null, null) THE_GEOM,
1 EXPL_ID
--FROM NA_MATARO.CAT_T_NUM_POSTALS
FROM NA_MATARO.CAT_T_NUM_POSTALS
) T;
/*
NA. CAT vs GEO
SELECT T1.CODI, T1.TIPUS_VIA || ' ' || T1.AUX || ' ' || T1.NOM, 'CAT_T_CARRER' TAULA
FROM NA_MATARO.CAT_T_CARRER T1
LEFT JOIN NA_MATARO.BASE_EIX_CARRER T2 ON T1.CODI = T2.CARRER_ID
WHERE T2.CARRER_ID IS NULL
UNION
SELECT T2.CARRER_ID, T2.CARRER_NOM, 'BASE_EIX_CARRER'
FROM NA_MATARO.CAT_T_CARRER T1
RIGHT JOIN NA_MATARO.BASE_EIX_CARRER T2 ON T1.CODI = T2.CARRER_ID
WHERE T1.CODI IS NULL;
NA. CAT vs NOMENCLATOR
[OK] SELECT T2.*
FROM NA_MATARO.CAT_T_CARRER T1
RIGHT JOIN ZZ_NOMENCLATOR T2 ON T1.CODI = T2.CODI_CARRER
WHERE T1.CODI IS NULL
AND T2.CODI_CARRER IS NOT NULL;
NA vs NS :: OK
[OK] SELECT T1.CODI, T1.TIPUS_VIA || ' ' || T1.AUX || ' ' || T1.NOM, 'NA_MATARO' TAULA
FROM NA_MATARO.CAT_T_CARRER T1
LEFT JOIN NS_MATARO.CAT_T_CARRER T2 ON T1.CODI = T2.CODI
WHERE T2.CODI IS NULL
UNION
SELECT T2.CODI, T2.TIPUS_VIA || ' ' || T2.AUX || ' ' || T2.NOM, 'NS_MATARO'
FROM NA_MATARO.CAT_T_CARRER T1
RIGHT JOIN NS_MATARO.CAT_T_CARRER T2 ON T1.CODI = T2.CODI
WHERE T1.CODI IS NULL;
[OK] SELECT T1.* , T2.*
FROM NA_MATARO.CAT_T_CARRER T1
LEFT JOIN NS_MATARO.CAT_T_CARRER T2 ON T1.CODI = T2.CODI
WHERE T1.NOM <> T2.NOM;
---
[ok] SELECT T1.CARRER_ID, T1.CARRER_NOM, 'NA_MATARO' TAULA
FROM NA_MATARO.BASE_EIX_CARRER T1
LEFT JOIN NS_MATARO.BASE_EIX_CARRER T2 ON T1.CARRER_ID = T2.CARRER_ID
WHERE T2.CARRER_ID IS NULL
UNION
SELECT T2.CARRER_ID, T2.CARRER_NOM, 'NS_MATARO'
FROM NA_MATARO.BASE_EIX_CARRER T1
RIGHT JOIN NS_MATARO.BASE_EIX_CARRER T2 ON T1.CARRER_ID = T2.CARRER_ID
WHERE T1.CARRER_ID IS NULL;
NS. CAT vs GEO
SELECT T1.CODI, T1.TIPUS_VIA || ' ' || T1.AUX || ' ' || T1.NOM, 'CAT_T_CARRER' TAULA
FROM NS_MATARO.CAT_T_CARRER T1
LEFT JOIN NS_MATARO.BASE_EIX_CARRER T2 ON T1.CODI = T2.CARRER_ID
WHERE T2.CARRER_ID IS NULL
UNION
SELECT T2.CARRER_ID, T2.CARRER_NOM, 'BASE_EIX_CARRER'
FROM NS_MATARO.CAT_T_CARRER T1
RIGHT JOIN NS_MATARO.BASE_EIX_CARRER T2 ON T1.CODI = T2.CARRER_ID
WHERE T1.CODI IS NULL;
NS. CAT vs NOMENCLATOR
[OK] SELECT T2.*
FROM NS_MATARO.CAT_T_CARRER T1
RIGHT JOIN ZZ_NOMENCLATOR T2 ON T1.CODI = T2.CODI_CARRER
WHERE T1.CODI IS NULL
AND T2.CODI_CARRER IS NOT NULL;
*/
|
-- --------------------------------------------------------
--
-- Estrutura da tabela `tb_pessoa_email`
--
CREATE TABLE `tb_pessoa_email` (
`codigo` int(11) NOT NULL,
`pessoa` int(11) NOT NULL,
`email` varchar(255) DEFAULT NULL,
`descricao` varchar(45) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1; |
create procedure AGREGAR_EDITAR
(
IN _id INT,
IN _name varchar(50),
IN _salary INT
)
BEGIN
IF _id = 0 THEN
INSERT INTO empleados (name, salary)
VALUES (_name, _salary);
SET _id = LAST_INSERT_ID();
ELSE
UPDATE empleados
SET
name = _name,
salary = _salary,
WHERE id = _id
END IF
SELECT _id AS id
END |
DROP DATABASE IF EXISTS bamazon;
CREATE DATABASE bamazon;
USE bamazon;
CREATE TABLE products(
item_id INT AUTO_INCREMENT NOT NULL,
product_name VARCHAR(45) NOT NULL,
department_name VARCHAR(45) NOT NULL,
price DECIMAL(10,2) NOT NULL,
stock_quantity INT(10) NOT NULL,
primary key(item_id)
);
SELECT * FROM products;
INSERT INTO products (product_name, department_name, price, stock_quantity)
VALUES ("God of War", "Video Games", 50, 10),
("Monster Hunter World", "Video Games", 50, 100),
("Ice Cream", "Food and Drink", 50, 10),
("Tank Top", "Apparel", 50, 15),
("Shorts", "Apparel", 50, 15),
("Soap", "Necessities", 50, 10),
("Titanic", "Films", 50, 10),
("Resident Evil", "Films", 50, 10),
("Life", "Board Games", 50, 10),
("Dungeons and Dragons", "Board Games", 50, 10);
|
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id('[Sys_AppSetting]') AND OBJECTPROPERTY(id, 'IsUserTable') = 1)
DROP TABLE [Sys_AppSetting]
;
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id('[Sys_DBConnection]') AND OBJECTPROPERTY(id, 'IsUserTable') = 1)
DROP TABLE [Sys_DBConnection]
;
CREATE TABLE [Sys_AppSetting]
(
[AppSettingKey] nvarchar(100) NOT NULL,
[AppSettingValue] nvarchar(2000) NULL,
[Description] nvarchar(2000) NULL,
[GroupKey] nvarchar(100) NULL,
[SortIndex] bigint NULL,
[CreateTime] datetime NOT NULL DEFAULT GETDATE(),
[LastModifyTime] datetime NOT NULL DEFAULT GETDATE()
)
;
CREATE TABLE [Sys_DBConnection]
(
[DBKey] nvarchar(100) NOT NULL,
[ConnectionString] nvarchar(2000) NULL,
[ProviderName] nvarchar(200) NULL,
[Description] nvarchar(2000) NULL,
[GroupKey] nvarchar(100) NULL,
[SortIndex] bigint NULL,
[CreateTime] datetime NOT NULL DEFAULT GETDATE(),
[LastModifyTime] datetime NOT NULL DEFAULT GETDATE()
)
;
ALTER TABLE [Sys_AppSetting]
ADD CONSTRAINT [PK_Sys_AppSetting]
PRIMARY KEY CLUSTERED ([AppSettingKey])
;
ALTER TABLE [Sys_DBConnection]
ADD CONSTRAINT [PK_Sys_DBConnection]
PRIMARY KEY CLUSTERED ([DBKey])
;
|
USE Ecommerce ;
DROP PROCEDURE IF EXISTS Return_Category;
DELIMITER //
CREATE PROCEDURE Return_Category(IN Num INT)
BEGIN
IF (Num = 0 ) THEN
SELECT *FROM CATEGORY
;
ELSE
SELECT * FROM CATEGORY
LIMIT 0, Num
;
END IF ;
END //
DELIMITER ;
|
//
CREATE PROCEDURE insert_user(IN _pseudo VARCHAR(40),IN _nom VARCHAR(100),
IN _prenom VARCHAR(100),IN _password VARCHAR(64),IN _dateNaissance DATE,
IN _type VARCHAR(30),IN _email VARCHAR(255),IN _telephone VARCHAR(14),
IN _cellulaire VARCHAR(14),IN _noCivique VARCHAR(10),IN _rue VARCHAR(80),
IN _ville VARCHAR(80),IN _codePostal VARCHAR(7),IN _avatar VARCHAR(255),
IN _points INT(11),IN _intervalNotification INT(13),IN _textNotification tinyint(1),
IN _emailNotification tinyint(1))
INSERT INTO users (pseudo, nom, prenom, password,dateNaissance,type,
email,telephone,cellulaire,noCivique,rue, ville, codePostal,avatar,
points,intervalNotification,textNotification,emailNotification)
VALUES (_pseudo, _nom, _prenom, _password,_dateNaissance,_type,
_email,_telephone,_cellulaire,_noCivique,_rue,_ville, _codePostal,
_avatar,_points,_intervalNotification,_textNotification,_emailNotification);
return LAST_INSERT_ID();
// |
PROMPT
SET ECHO ON
SELECT * FROM KLASA_SEDZIEGO;
SET ECHO OFF
PROMPT |
CREATE OR REPLACE FUNCTION zerobyte._NOT_NULL_ZEROBYTE_TO_INT64(a ARRAY< STRUCT< _ STRUCT< _ INT64 >
> >)
AS (
(
SELECT
SUM(`IF`(_ IS NULL, 0, 1 << o))
FROM
UNNEST(a) WITH OFFSET AS o
)
);
|
-- database dump of hbtn_0d_tvshows to your MySQL server: download
SELECT
tv_shows.title,
tv_show_genres.genre_id
FROM
tv_shows
LEFT JOIN tv_show_genres ON tv_shows.id = tv_show_genres.show_id
WHERE
tv_show_genres.genre_id IS NULL
ORDER BY
tv_shows.title ASC,
tv_show_genres.genre_id ASC;
|
USE Diablo
--EXCERCISE 13
CREATE FUNCTION ufn_CashInUsersGames (@gameName NVARCHAR(50))
RETURNS TABLE
AS
RETURN
SELECT SUM(r.Cash) AS [SumCash]
FROM(
SELECT ug.Cash, ROW_NUMBER() OVER (ORDER BY ug.Cash DESC) AS [Row]
FROM UsersGames AS ug
JOIN Games AS g
ON g.Id = ug.GameId
WHERE g.[Name] = @gameName) AS r
WHERE r.Row % 2 <> 0
SELECT * FROM dbo.ufn_CashInUsersGames ('Love in a mist') |
-- Database: MyCompany
-- DROP DATABASE "MyCompany";
CREATE DATABASE "MyCompany"
WITH
OWNER = postgres
ENCODING = 'UTF8'
LC_COLLATE = 'English_United States.1252'
LC_CTYPE = 'English_United States.1252'
TABLESPACE = pg_default
CONNECTION LIMIT = -1;
-- Table: public.product
-- DROP TABLE public.product;
CREATE TABLE public.product
(
deleted boolean NOT NULL,
description text COLLATE pg_catalog."default" NOT NULL,
id integer NOT NULL DEFAULT nextval('product_id_seq'::regclass),
name text COLLATE pg_catalog."default" NOT NULL,
active boolean NOT NULL,
product_type_id integer,
CONSTRAINT product_pkey PRIMARY KEY (id),
CONSTRAINT product_type_fk FOREIGN KEY (product_type_id)
REFERENCES public.product_type (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE public.product
OWNER to postgres;
-- Index: fki_ProductTypeFK
-- DROP INDEX public."fki_ProductTypeFK";
CREATE INDEX "fki_ProductTypeFK"
ON public.product USING btree
(product_type_id)
TABLESPACE pg_default;
-- Table: public.product_type
-- DROP TABLE public.product_type;
CREATE TABLE public.product_type
(
id integer NOT NULL DEFAULT nextval('product_type_id_seq'::regclass),
name text COLLATE pg_catalog."default" NOT NULL,
description text COLLATE pg_catalog."default" NOT NULL,
deleted boolean NOT NULL,
CONSTRAINT product_type_pkey PRIMARY KEY (id)
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE public.product_type
OWNER to postgres;
-- Database: MyCompanyWarehouse
-- DROP DATABASE "MyCompanyWarehouse";
CREATE DATABASE "MyCompanyWarehouse"
WITH
OWNER = postgres
ENCODING = 'UTF8'
LC_COLLATE = 'English_United States.1252'
LC_CTYPE = 'English_United States.1252'
TABLESPACE = pg_default
CONNECTION LIMIT = -1;
-- Table: public.dim_product
-- DROP TABLE public.dim_product;
CREATE TABLE public.dim_product
(
id integer NOT NULL DEFAULT nextval('dim_product_id_seq'::regclass),
application_product_id integer,
application_product_type_id integer,
product_type_name text COLLATE pg_catalog."default",
product_type_description text COLLATE pg_catalog."default",
product_name text COLLATE pg_catalog."default",
product_description text COLLATE pg_catalog."default",
CONSTRAINT dim_product_pkey PRIMARY KEY (id)
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE public.dim_product
OWNER to postgres;
CREATE USER "Gene" WITH
LOGIN
SUPERUSER
INHERIT
CREATEDB
CREATEROLE
REPLICATION; |
SELECT
min(duration) min_duration,
trip_id,
start_station,
end_station
FROM
trips
|
delete
from annotation
where file_path ='/data/dataset_p02/root/0000000000/009/022/090.xml' |
CREATE TABLE [ERP].[Cliente] (
[ID] INT IDENTITY (1, 1) NOT NULL,
[IdEntidad] INT NULL,
[IdEmpresa] INT NOT NULL,
[IdVendedor] INT NULL,
[IdTipoRelacion] INT NULL,
[FechaRegistro] DATETIME NULL,
[FechaEliminado] DATETIME NULL,
[FlagBorrador] BIT NULL,
[Flag] BIT NULL,
[FechaModificado] DATETIME NULL,
[UsuarioRegistro] VARCHAR (250) NULL,
[UsuarioModifico] VARCHAR (250) NULL,
[UsuarioElimino] VARCHAR (250) NULL,
[UsuarioActivo] VARCHAR (250) NULL,
[FechaActivacion] DATETIME NULL,
[Correo] VARCHAR (250) NULL,
[DiasVencimiento] INT NULL,
[FlagClienteBoleta] BIT NULL,
[AgenteRetencion] BIT NULL,
CONSTRAINT [PK__Cliente__3214EC2700CC47AF] PRIMARY KEY CLUSTERED ([ID] ASC),
CONSTRAINT [FK__Cliente__IdEmpre__062DE679] FOREIGN KEY ([IdEmpresa]) REFERENCES [ERP].[Empresa] ([ID]),
CONSTRAINT [FK__Cliente__IdEntid__0539C240] FOREIGN KEY ([IdEntidad]) REFERENCES [ERP].[Entidad] ([ID]),
CONSTRAINT [FK_Cliente_TipoRelacion] FOREIGN KEY ([IdTipoRelacion]) REFERENCES [Maestro].[TipoRelacion] ([ID]),
CONSTRAINT [FK_Cliente_Vendedor] FOREIGN KEY ([IdVendedor]) REFERENCES [ERP].[Vendedor] ([ID])
);
|
SELECT
T2.FACTORING_STATUS --T2.放款状态
, T2.DISPUTE_STATUS --T2.商纠状态
, T2.CANCEL_FLG --T2.取消状态
, T2.TRADE_EXCEPTION_TYPE --T2.账款异常种类
, T2.INVOICE_NO --T2.债权号
, T2.INVOICE_ID --T2.债权ID
, ISNULL(T4.CREDIT_NOTE,0) AS CREDIT_NOTE --T4.贷项清单
, ISNULL(T6.ACCOUNTS_ABNORMAL,0) AS ACCOUNTS_ABNORMAL --T6.账款异常
, T7.FROZEN_FLAG --T7.冻结与否
, T1.PAY_ID --T1.付款申请流水号
, T7.CONTRACT_NO --T7.买卖关联号
, T2.FINISH_STATUS --T2.结清状态
FROM
F_PAY_INFO AS T1 --支付
INNER JOIN
INVOICE_INFO AS T2 --债权
/* 保理产品化step2 huangchenggang 2015/06/15 要件1 start*/
-- ON T2.INVOICE_ID = T1.FINANCING_APPLY_NO --T2.债权ID = T1.业务申请号
ON T2.INVOICE_NO = T1.FINANCING_APPLY_NO --T2.债权号 = T1.业务申请号
/* 保理产品化step2 huangchenggang 2015/06/15 要件1 end*/
LEFT JOIN
(
SELECT
T3.INVOICE_ID --债权ID
, COUNT(1) AS CREDIT_NOTE --贷项清单
FROM
CREDIT_NOTE_APPLY_INFO AS T3 --贷项清单
WHERE
T3.STATUS = /*applyStatus*/'02' --T2.申请状态 = 02(申请中))
GROUP BY
T3.INVOICE_ID
) AS T4
ON T4.INVOICE_ID = T2.INVOICE_ID
LEFT JOIN
(
SELECT
T5.INVOICE_ID --债权 ID
, COUNT(1) AS ACCOUNTS_ABNORMAL --账款异常
FROM
ACCOUNTS_ABNORMAL_APPLY_INFO AS T5 --账款异常
WHERE
T5.ACCOUNTS_ABNORMAL_STATE = /*applyStatus*/'02' --T5.申请状态 = 02(申请中))
AND T5.ACCOUNTS_ABNORMAL_APPLY_TYPE = /*applyType*/'1' --T5.账款异常申请类型 = 1 (异常申请)
GROUP BY
T5.INVOICE_ID
) AS T6
ON T6.INVOICE_ID = T2.INVOICE_ID
INNER JOIN
FCONTRACT_BASEINFO AS T7 --买卖关联
ON T7.CONTRACT_ID = T2.CONTRACT_ID --T7.买卖关联ID = T2. 买卖关联ID
WHERE
T1.PAY_ID IN /*payIdArray*/('') --T1.付款申请流水号 in 参数.付款申请流水号数组
|
SELECT
APPLY_NO AS CONTRACT_NO, --契約番号
SUPPLIES_NO, --物件番号
PAY_TYPE , --支払種別
PAY_NO , --支払番号
PAY_SIGHT , --支払サイト
PAY_SCHEDULED_DATE --支払予定日
FROM
APPLY_PAY_INFO P
WHERE
APPLY_NO = /*applyNo*/ AND SUPPLIES_NO = /*supplyNo*/
AND PAY_TYPE = CAST(/*payType*/ AS CHAR(1))
ORDER BY
PAY_NO ASC |
drop table if exists tally;
create table tally (
id integer primary key,
text varchar(255),
count integer
);
|
SELECT
--T2.实际付款额
T2.ACTUAL_PAYMENT,
--T3.融资还款额
T3.FINANCING_REPAYMENT_AMOUNT,
--T2.放款额 AS 融资额
T2.FINANCING_AMOUNT,
--(T2.放款额 - T3.融资还款额 ) AS 融资余额
(T2.FINANCING_AMOUNT - T3.FINANCING_REPAYMENT_AMOUNT) AS FINANCING_BALANCE,
--T3.放款状态
T3.FACTORING_STATUS,
--CODE1.CODE_NAME as 放款状态名称
CODE1.CODE_NAME AS ACTUAL_PAYMENT_STATE_NAME,
--T1.放款类型
T1.FINANCING_TYPE,
--T1.放款申请状态
T1.FINANCING_STATE,
--T1.放款申请号 AS 融资申请号
T1.FINANCING_APPLY_NO,
--T1.放款付款预定日
T1.PAYMENT_SCHEDULE_DATE,
--T1.融资利率
T1.FINANCING_RATES,
--T1.融资利率单位
T1.FINANCING_UNIT,
--T1.融资利率天数
T1.FINANCING_UNIT_DAYS,
--T1.币种
T1.CURRENCY_ID
--FROM 放款申请信息 T1
FROM
FINANCING_APPLY_INFO T1
--INNER JOIN 放款申请明细信息 T2
INNER JOIN FINANCING_APPLY_DETAIL_INFO T2
--ON T1.放款申請号 = T2.放款申請号
ON T1.FINANCING_APPLY_NO = T2.FINANCING_APPLY_NO
--INNER JOIN 债权 T3
INNER JOIN INVOICE_INFO T3
--ON T2.债权ID = T3.债权ID
ON T2.INVOICE_ID = T3.INVOICE_ID
--LEFT JOIN コードマスタ CODE1
LEFT JOIN CODE_MASTER CODE1
--ON T3.放款状态 = CODE1.CODE_ID
ON T3.FACTORING_STATUS = CODE1.CODE_ID
--AND CODE1.国ID = 参数.国ID
AND CODE1.COUNTRY_ID = /*dto.countryId*/''
--AND CODE1.CODE_TYPE = 449 放款状态
AND CODE1.CODE_TYPE = /*dto.codeKbnFactoringStatus*/''
--WHERE 债权表.债权ID = 参数.债权ID
WHERE T3.INVOICE_ID = /*dto.invoiceId*/''
--AND T1.取消状态 = 1:未撤销(CODEMASTER:015)
AND T1.CANCAL_STATE = /*dto.codeKbnCancelStatus*/''
--AND T1.放款申请状态 = 03:已审批 (CODEMASTER:420)
AND T1.FINANCING_STATE = /*dto.codeKbnFinancingApplyStatusApproved*/'' |
undefine l_id_debug_group
undefine l_sessionId
undefine l_filter
define l_id_debug_group = "&1"
define l_sessionId = "&2"
define l_filter = "&3"
set feedback on
prompt .. Setting debug on for session in debug group. (debug_group="&&l_id_debug_group", sessionId="&&l_sessionId", filter="&&l_filter")
set feedback off
declare
l_id_debug_group integer := to_number('&&l_id_debug_group');
l_sessionId integer := to_number('&&l_sessionId');
l_filter varchar2(4000):= nvl('&&l_filter', '*');
begin
debug_adm.debug_other(l_id_debug_group, l_sessionId, l_filter);
end;
/
set feedback on
prompt done
prompt
set termout on
undefine l_id_debug_group
undefine l_sessionId
undefine l_filter
|
INSERT INTO `lacosbaby`.`tb_permission` (`pk_id`, `role`)
VALUES ('1', 'ROLE_ADMIN');
INSERT INTO `lacosbaby`.`tb_permission` (`pk_id`, `role`)
VALUES ('2', 'ROLE_USER');
INSERT INTO `lacosbaby`.`tb_permission` (`pk_id`, `role`)
VALUES ('3', 'ROLE_VISITANTE');
INSERT INTO `lacosbaby`.`tb_user` (`pk_id`, `name`, `email`, `password`)
VALUES ('1', 'Admin', 'admin@admin.com', '9fe76e18dd29100230680fa6c812e26c4da4b3cf48a85850910e6f4400a6b3ff9ec05190c175f592');
INSERT INTO `lacosbaby`.`tb_user_permission` (`permission_id`, `user_id`) VALUES ('1', '1'); |
--
-- HIERARCHY
--
DROP TABLE IF EXISTS wards;
CREATE TABLE wards
(
ward_id INTEGER NOT NULL,
ward_name VARCHAR(100) NOT NULL,
constituency_id INTEGER NOT NULL
);
DROP TABLE IF EXISTS constituencies;
CREATE TABLE constituencies
(
constituency_id INTEGER NOT NULL,
constituency_name VARCHAR(100) NOT NULL,
district_id INTEGER NOT NULL
);
DROP TABLE IF EXISTS school_positions;
CREATE TABLE school_positions
(
emis_id INTEGER NOT NULL,
gis_long FLOAT NOT NULL,
gis_lat FLOAT NOT NULL
);
DROP TABLE IF EXISTS schools;
CREATE TABLE schools
(
emis_id INTEGER NOT NULL,
school_name VARCHAR(100) NOT NULL,
school_level_id TINYINT,
school_type_id TINYINT
);
DROP TABLE IF EXISTS schools_shehia_hierarchy;
CREATE TABLE schools_shehia_hierarchy
(
emis_id INTEGER NOT NULL,
shehia_id INTEGER NOT NULL
);
DROP TABLE IF EXISTS schools_cluster_hierarchy;
CREATE TABLE schools_cluster_hierarchy
(
emis_id INTEGER NOT NULL,
cluster_id INTEGER NOT NULL
);
DROP TABLE IF EXISTS lookup_school_types;
CREATE TABLE lookup_school_types
(
school_type_id TINYINT NOT NULL PRIMARY KEY,
school_type_name CHAR(32) NOT NULL
);
INSERT INTO lookup_school_types VALUES
(0, "government"),
(1, "private");
DROP TABLE IF EXISTS districts;
CREATE TABLE districts
(
district_id INTEGER NOT NULL,
district_name VARCHAR(100) NOT NULL,
region_id INTEGER NOT NULL
);
DROP TABLE IF EXISTS teacher_centers;
CREATE TABLE teacher_centers
(
tc_id INTEGER NOT NULL,
tc_name VARCHAR(100) NOT NULL,
island_id INTEGER NOT NULL
);
DROP TABLE IF EXISTS clusters;
CREATE TABLE clusters
(
cluster_id INTEGER NOT NULL,
cluster_name VARCHAR(100) NOT NULL,
tc_id INTEGER NOT NULL
);
DROP TABLE IF EXISTS shehias;
CREATE TABLE shehias
(
shehia_id INTEGER NOT NULL,
shehia_name VARCHAR(100) NOT NULL,
ward_id INTEGER NOT NULL
);
DROP TABLE IF EXISTS regions;
CREATE TABLE regions
(
region_id INTEGER NOT NULL,
region_name VARCHAR(100) NOT NULL,
island_id INTEGER NOT NULL
);
DROP TABLE IF EXISTS islands;
CREATE TABLE islands
(
island_id INTEGER NOT NULL,
island_name VARCHAR(100) NOT NULL,
nation_id INTEGER NOT NULL
);
DROP TABLE IF EXISTS nation;
CREATE TABLE nation
(
nation_id INTEGER NOT NULL,
nation_name VARCHAR(100) NOT NULL
);
--
-- ENROLMENT
--
DROP TABLE IF EXISTS enrolments;
CREATE TABLE enrolments
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
education_level_id TINYINT NOT NULL,
grade_id TINYINT NOT NULL,
gender_id TINYINT NOT NULL,
qty INTEGER NOT NULL
);
DROP TABLE IF EXISTS enrolment_dropouts;
CREATE TABLE enrolment_dropouts
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
gender_id TINYINT NOT NULL,
grade_id TINYINT NOT NULL,
qty INTEGER NOT NULL
);
DROP TABLE IF EXISTS enrolment_repeaters;
CREATE TABLE enrolment_repeaters
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
gender_id TINYINT NOT NULL,
grade_id TINYINT NOT NULL,
qty INTEGER NOT NULL
);
DROP TABLE if exists enrolment_entrants_post2017;
CREATE TABLE enrolment_entrants_post2017
(
id int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id int(11) NOT NULL,
year int(11) NOT NULL,
gender_id tinyint(4) NOT NULL,
education_level_id tinyint(4) NOT NULL,
age tinyint(4) NOT NULL,
PPE_status_id tinyint(4) NOT NULL,
qty int(11) NOT NULL
);
DROP TABLE IF EXISTS enrolment_entrants_ages_pre2018;
CREATE TABLE enrolment_entrants_ages_pre2018
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
education_level_id TINYINT NOT NULL,
gender_id TINYINT NOT NULL,
age TINYINT NOT NULL,
qty INTEGER NOT NULL
);
DROP TABLE IF EXISTS enrolment_entrants_educations_pre2018;
CREATE TABLE enrolment_entrants_educations_pre2018
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
education_level_id TINYINT NOT NULL,
gender_id TINYINT NOT NULL,
educated TINYINT NOT NULL,
qty INTEGER NOT NULL
);
DROP VIEW IF EXISTS enrolment_entrants_ages;
CREATE VIEW enrolment_entrants_ages
AS
SELECT emis_id, year, education_level_id, gender_id, age, qty FROM enrolment_entrants_ages_pre2018
UNION
SELECT emis_id, year, education_level_id, gender_id, age, SUM(qty) as qty
FROM enrolment_entrants_post2017
GROUP BY emis_id, year, education_level_id, gender_id, age;
DROP VIEW IF EXISTS enrolment_entrants_educations;
CREATE VIEW enrolment_entrants_educations
AS
SELECT emis_id, year, education_level_Id, gender_id, IF(educated, 1, 2) as ppe_status, qty FROM enrolment_entrants_educations_pre2018
UNION
SELECT emis_id, year, education_level_Id, gender_id, PPE_status_id as ppe_status, SUM(qty) as qty
FROM enrolment_entrants_post2017
GROUP BY emis_id, year, education_level_Id, gender_id, PPE_status_id;
DROP TABLE IF EXISTS enrolment_ages;
CREATE TABLE enrolment_ages
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
age TINYINT NOT NULL,
education_level_id TINYINT NOT NULL,
grade_id TINYINT NOT NULL,
gender_id TINYINT NOT NULL,
qty INTEGER NOT NULL
);
DROP TABLE IF EXISTS enrolment_ages_ss;
CREATE TABLE enrolment_ages_ss
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
age TINYINT NOT NULL,
education_level_id TINYINT NOT NULL,
grade_id TINYINT NOT NULL,
gender_id TINYINT NOT NULL,
qty INTEGER NOT NULL
);
DROP VIEW IF EXISTS enrolment_without_repeaters_items;
CREATE VIEW enrolment_without_repeaters_items AS
SELECT emis_id, year, grade_id, gender_id, qty
FROM enrolment_ages
UNION
SELECT emis_id, year, grade_id, gender_id, -1 * qty as qty
FROM enrolment_repeaters;
DROP VIEW IF EXISTS enrolment_without_repeaters;
CREATE VIEW enrolment_without_repeaters AS
SELECT emis_id, year, grade_id, gender_id, sum(qty) as qty
FROM enrolment_without_repeaters_items
GROUP BY emis_id, year, grade_id, gender_id;
DROP VIEW IF EXISTS withSurveySolutionData;
CREATE VIEW withSurveySolutionData AS
SELECT emis_id, year FROM enrolment_ages_ss WHERE qty > 0 GROUP BY emis_id, year;
DROP TABLE IF EXISTS enrolment_disabilities_pre2018;
CREATE TABLE enrolment_disabilities_pre2018
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
education_level_id TINYINT NOT NULL,
gender_id TINYINT NOT NULL,
disability_id TINYINT NOT NULL,
qty INTEGER NOT NULL
);
DROP TABLE IF EXISTS lookup_disabilities;
CREATE TABLE lookup_disabilities
(
disability_id TINYINT NOT NULL PRIMARY KEY,
disability_name CHAR(32) NOT NULL
);
DELETE FROM lookup_disabilities;
INSERT INTO lookup_disabilities VALUES
(0, "Visual"),
(1, "Physical"),
(2, "Deaf"),
(3, "Mute"),
(4, "Mental"),
(5, "Mixed"),
(6, "Other"),
(7, "Visual Partial"),
(8, "Albino");
--
-- CLASSROOMS
-- (source DATASET_BAJETI)
DROP TABLE IF EXISTS classrooms;
CREATE TABLE classrooms
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
education_level_id TINYINT NOT NULL,
qty INTEGER NOT NULL,
classrooms_notused INTEGER,
classrooms_good INTEGER,
classrooms_major_repairs INTEGER,
classrooms_new_constructions INTEGER
);
DROP TABLE IF EXISTS classrooms_ss;
CREATE TABLE classrooms_ss
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
education_level_id TINYINT NOT NULL,
qty INTEGER NOT NULL,
classrooms_notused INTEGER,
classrooms_good INTEGER,
classrooms_major_repairs INTEGER,
classrooms_new_constructions INTEGER
);
--
-- TEACHERS
--
DROP TABLE IF EXISTS teacher_attritions;
CREATE TABLE teacher_attritions
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
education_level_id TINYINT NOT NULL,
gender_id TINYINT NOT NULL,
teacher_edu_condensed_id TINYINT NOT NULL,
qty INTEGER NOT NULL
);
DROP TABLE IF EXISTS teacher_experiences;
CREATE TABLE teacher_experiences
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
education_level_id TINYINT NOT NULL,
gender_id TINYINT NOT NULL,
teacher_experience_id TINYINT NOT NULL,
qty INTEGER NOT NULL
);
DROP TABLE IF EXISTS teacher_multilevels_pre2018;
CREATE TABLE teacher_multilevels_pre2018
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
education_level_id TINYINT NOT NULL,
gender_id TINYINT NOT NULL,
teacher_edu_condensed_id TINYINT NOT NULL,
qty INTEGER NOT NULL
);
DROP TABLE IF EXISTS teacher_subject_taught;
CREATE TABLE teacher_subject_taught
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
education_level_id TINYINT NOT NULL,
gender_id TINYINT NOT NULL,
subject_id INTEGER NOT NULL,
teacher_edu_condensed_id TINYINT NOT NULL,
qty INTEGER NOT NULL
);
DROP TABLE IF EXISTS population;
CREATE TABLE population
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
district_id INTEGER NOT NULL,
year INTEGER NOT NULL,
gender_id TINYINT NOT NULL,
age TINYINT NOT NULL,
qty INTEGER
);
DROP TABLE IF EXISTS enrolment_school_leavers;
CREATE TABLE enrolment_school_leavers
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
education_level_id TINYINT NOT NULL,
leaver_id TINYINT NOT NULL,
gender_id TINYINT NOT NULL,
qty INTEGER
);
DROP TABLE IF EXISTS lookup_leaver;
CREATE TABLE lookup_leaver
(
leaver_id TINYINT NOT NULL PRIMARY KEY,
leaver_name CHAR(32) NOT NULL
);
DELETE FROM lookup_leaver;
INSERT INTO lookup_leaver VALUES
(0, "Enumerator"),
(1, "Denominator");
DROP TABLE IF EXISTS lookup_teacher_experiences;
CREATE TABLE lookup_teacher_experiences
(
experience_id TINYINT NOT NULL PRIMARY KEY,
experience_name CHAR(32) NOT NULL
);
INSERT INTO lookup_teacher_experiences VALUES
(0, "0-5"),
(1, "6-10"),
(2, "11-15"),
(3, "16-20"),
(4, "21-25"),
(5, "26-30"),
(6, "30+");
--
-- TOILETS
--
DROP TABLE IF EXISTS toilets;
CREATE TABLE toilets
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
education_level_id TINYINT NOT NULL,
toilet_id TINYINT NOT NULL,
qty INTEGER NOT NULL
);
DROP VIEW IF EXISTS toilets_functional;
CREATE VIEW toilets_functional AS
(SELECT emis_id, year, education_level_id, 0 as gender_id, sum(qty) as qty FROM toilets
WHERE toilet_id IN (0, 2, 4, 5)
GROUP BY emis_id, year, education_level_id)
UNION
(SELECT emis_id, year, education_level_id, 1 as gender_id, sum(qty) as qty FROM toilets
WHERE toilet_id IN (1, 3, 4, 5)
GROUP BY emis_id, year, education_level_id);
DROP TABLE IF EXISTS toilets_gender;
CREATE TABLE toilets_gender
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
education_level_id TINYINT NOT NULL,
gender_id TINYINT NOT NULL,
qty INTEGER NOT NULL
);
DROP TABLE IF EXISTS lookup_toilets;
CREATE TABLE lookup_toilets
(
toilet_id TINYINT NOT NULL PRIMARY KEY,
toilet_name CHAR(32) NOT NULL
);
INSERT INTO lookup_toilets VALUES
(0, "male"),
(1, "female"),
(2, "teacher"),
(3, "pupils mixed"),
(4, "pupil/teacher"),
(5, "disabled");
--
-- FURNITURE
DROP TABLE IF EXISTS furnitures;
CREATE TABLE furnitures
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
education_level_id TINYINT NOT NULL,
furniture_id TINYINT NOT NULL,
qty INTEGER NOT NULL
);
DROP TABLE IF EXISTS lookup_furnitures;
CREATE TABLE lookup_furnitures
(
furniture_id TINYINT NOT NULL PRIMARY KEY,
furniture_name CHAR(32) NOT NULL
);
INSERT INTO lookup_furnitures VALUES
(0, "1 pupil desk"),
(1, "2 pupil desk"),
(2, "3 pupil desk"),
(3, "chair"),
(4, "1 pupil table"),
(5, "2 pupil table");
--
-- TEXTBOOKS
DROP TABLE IF EXISTS textbooks;
CREATE TABLE textbooks
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
grade_id TINYINT NOT NULL,
subject_id INTEGER NOT NULL,
qty INTEGER NOT NULL
);
DROP TABLE IF EXISTS lookup_subjects;
CREATE TABLE lookup_subjects
(
subject_id INTEGER NOT NULL PRIMARY KEY,
subject_name CHAR(32) NOT NULL,
education_level_id TINYINT NOT NULL
);
DELETE FROM lookup_subjects;
INSERT INTO lookup_subjects VALUES
(0, "Lugha", 0),
(1, "Dini ya Kiislam", 0),
(2, "Hisabati", 0),
(3, "Mazingira", 0),
(4, "Michezo", 0),
(5, "Sanaa na Ufundi", 0),
(6, "Kiarabu", 0),
(100, "Kiarabu", 1),
(101, "Kompyuta", 1),
(102, "Kiingereza", 1),
(103, "Dini", 1),
(104, "Kiswahili", 1),
(105, "Hisabati", 1),
(106, "Sayansi", 1),
(107, "Sayansi Jamii", 1),
(108, "Michezo", 1),
(109, "Elimu ya Amali", 1),
(110, "Geography", 1),
(111, "Historia", 1),
(112, "Uraia", 1),
(200, "Arabic", 2),
(201, "Biol", 2),
(202, "B.Keeping", 2),
(203, "Chem", 2),
(204, "Commer", 2),
(205, "Comp", 2),
(206, "Eng", 2),
(207, "Geog", 2),
(208, "Hist", 2),
(209, "Islamic", 2),
(210, "Kisw", 2),
(211, "Math", 2),
(212, "Phys", 2),
(213 ,"Civ", 2),
(214, "Physical Education", 2),
(215, "Economics", 2),
(216, "Fine Arts", 2),
(217, "French", 2);
DROP TABLE IF EXISTS lookup_genders;
CREATE TABLE lookup_genders
(
gender_id TINYINT NOT NULL PRIMARY KEY,
gender_name CHAR(2) NOT NULL
);
INSERT INTO lookup_genders VALUES
(0, 'm'),
(1, 'f');
DROP TABLE IF EXISTS lookup_school_levels;
CREATE TABLE lookup_school_levels
(
school_level_id TINYINT NOT NULL PRIMARY KEY,
school_level_name CHAR(16) NOT NULL
);
INSERT INTO lookup_school_levels VALUES
(0, 'Pre-Primary'),
(1, 'Primary'),
(2, 'Secondary'),
(3, 'Basic'),
(4, 'TuTu');
DROP TABLE IF EXISTS lookup_education_levels;
CREATE TABLE lookup_education_levels
(
education_level_id TINYINT NOT NULL PRIMARY KEY,
education_level_name CHAR(16) NOT NULL,
min_age TINYINT NOT NULL,
max_age TINYINT NOT NULL
);
INSERT INTO lookup_education_levels VALUES
(0, 'Pre-Primary', 4, 5),
(1, 'Primary', 6, 11),
(2, 'Secondary', 12, 18);
DROP TABLE IF EXISTS lookup_grades;
CREATE TABLE lookup_grades
(
grade_id TINYINT NOT NULL PRIMARY KEY,
grade_name CHAR(16) NOT NULL,
education_level_id TINYINT NOT NULL,
age TINYINT NOT NULL
);
INSERT INTO lookup_grades VALUES
(1, 'Nr', 0, 3),
(2, 'Jr', 0, 4),
(3, 'Sr', 0, 5),
(4, 'Std I', 1, 6),
(5, 'Std II', 1, 7),
(6, 'Std III', 1, 8),
(7, 'Std IV', 1, 9),
(8, 'Std V', 1, 10),
(9, 'Std VI', 1, 11),
(10, 'Std VII', 1, 12),
(11, 'Form I', 2, 12),
(12, 'Form II', 2, 13),
(13, 'Form III', 2, 14),
(14, 'Form IV', 2, 15),
(15, 'Form V', 2, 16),
(16, 'Form VI', 2, 17);
DROP TABLE IF EXISTS lookup_teacher_educations;
CREATE TABLE lookup_teacher_educations
(
teacher_education_id TINYINT NOT NULL PRIMARY KEY,
teacher_education_name CHAR(32) NOT NULL
);
INSERT INTO lookup_teacher_educations VALUES
(0, "Under F4"),
(1, "F4"),
(2, "F6"),
(3, "FTC"),
(4, "Diploma"),
(5, "Degree");
DROP TABLE IF EXISTS lookup_teacher_edu_condensed;
CREATE TABLE lookup_teacher_edu_condensed
(
teacher_edu_condensed_id TINYINT NOT NULL PRIMARY KEY,
teacher_edu_condensed_name CHAR(32) NOT NULL
);
INSERT INTO lookup_teacher_edu_condensed VALUES
(0, "Untrained"),
(1, "FTC"),
(2, "Diploma"),
(3, "Degree");
DROP TABLE IF EXISTS exam_passes;
CREATE TABLE exam_passes
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
gender_id TINYINT NOT NULL,
exam_grade_id TINYINT NOT NULL,
exam_level_id INTEGER NOT NULL,
qty INTEGER NOT NULL
);
DROP TABLE IF EXISTS exam_scores;
CREATE TABLE exam_scores
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
exam_grade_id TINYINT NOT NULL,
exam_subject_id TINYINT NOT NULL,
score FLOAT NOT NULL,
max_score FLOAT NOT NULL
);
DROP TABLE IF EXISTS lookup_exam_grades;
CREATE TABLE lookup_exam_grades
(
exam_grade_id TINYINT NOT NULL PRIMARY KEY,
exam_grade_name CHAR(32) NOT NULL
);
DELETE FROM lookup_exam_grades;
INSERT INTO lookup_exam_grades VALUES
(0, "Std IV"),
(1, "Std VI"),
(2, "Form II"),
(3, "Form IV"),
(4, "Form VI");
DROP TABLE IF EXISTS lookup_exam_levels;
CREATE TABLE lookup_exam_levels
(
exam_level_id TINYINT NOT NULL PRIMARY KEY,
exam_level_name CHAR(32) NOT NULL
);
DELETE FROM lookup_exam_levels;
INSERT INTO lookup_exam_levels VALUES
(0, "Failed"),
(1, "Passed"),
(2, "Excellent"),
(3, "Superior"),
(5, "Div 4"),
(6, "Div 3"),
(7, "Div 2"),
(8, "Div 1"),
(10, "Attended Exam"),
(11, "Missed Exam"),
(12, "Matriculated Form 5"),
(13, "Matriculated FTC");
DROP TABLE IF EXISTS lookup_exam_subjects;
CREATE TABLE lookup_exam_subjects
(
exam_subject_id TINYINT NOT NULL PRIMARY KEY,
exam_subject_name CHAR(32) NOT NULL
);
DELETE FROM lookup_exam_subjects;
INSERT INTO lookup_exam_subjects VALUES
(0, "ENG"),
(1, "KISW"),
(2, "DINI"),
(3, "KIAR"),
(4, "GEOG"),
(5, "CIVICS"),
(6, "HIST"),
(7, "CHEM"),
(8, "PHY"),
(9, "BIOL"),
(10, "MATH"),
(11, "URAIA"),
(12, "SCIENCE"),
(13, "ICT"),
(14, "SAYANSI"),
(15, "HISABATI");
DROP TABLE IF EXISTS schools_active;
CREATE TABLE schools_active
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
isActive BOOLEAN NOT NULL
);
DROP VIEW IF EXISTS schools_active_by_level;
CREATE VIEW schools_active_by_level AS
SELECT emis_id, year, e.education_level_id, 1 as isActive
FROM enrolment_ages e
INNER JOIN lookup_grades g ON g.grade_id = e.grade_id
WHERE qty > 0
GROUP BY emis_id, year, e.education_level_id;
DROP VIEW IF EXISTS schools_by_year;
CREATE VIEW schools_by_year AS
SELECT a.emis_id as emis_id, year, school_name, school_type_id, h.school_level_id
FROM schools h, schools_active a
WHERE h.emis_id = a.emis_id AND isActive = 1;
DROP VIEW IF EXISTS schools_shehia_hierarchy_by_year;
CREATE VIEW schools_shehia_hierarchy_by_year AS
SELECT a.emis_id as emis_id, year, shehia_id
FROM schools_shehia_hierarchy s, schools_active a
WHERE s.emis_id = a.emis_id AND isActive = 1;
DROP VIEW IF EXISTS schools_cluster_hierarchy_by_year;
CREATE VIEW schools_cluster_hierarchy_by_year AS
SELECT a.emis_id as emis_id, year, cluster_id
FROM schools_cluster_hierarchy c, schools_active a
WHERE c.emis_id = a.emis_id AND isActive = 1;
DROP VIEW IF EXISTS exam_attendance;
CREATE VIEW exam_attendance AS
SELECT emis_id, year, exam_grade_id, SUM(qty) as attended
FROM exam_passes
WHERE exam_level_id IN (10)
GROUP BY emis_id, year, exam_grade_id;
DROP VIEW IF EXISTS exam_total_score;
CREATE VIEW exam_total_score AS
SELECT es.emis_id, es.year, es.exam_grade_id, exam_subject_id, ROUND(score * attended) as total_score, ROUND(max_score * attended) as max_score, attended
FROM exam_scores es, exam_attendance ea
WHERE es.emis_id = ea.emis_id
AND es.year = ea.year
AND es.exam_grade_id = ea.exam_grade_id;
DROP VIEW IF EXISTS exam_gender_attendance;
CREATE VIEW exam_gender_attendance AS
SELECT emis_id, year, gender_id, exam_grade_id, SUM(qty) as attended
FROM exam_passes
WHERE exam_level_id IN (10)
GROUP BY emis_id, year, gender_id, exam_grade_id;
DROP VIEW IF EXISTS enrolment_by_level;
CREATE VIEW enrolment_by_level AS
SELECT emis_id, year, education_level_id, gender_id, SUM(qty) as qty
FROM enrolment_ages
GROUP BY emis_id, year, education_level_id, gender_id;
DROP VIEW IF EXISTS enrolment_repeaters_by_level;
CREATE VIEW enrolment_repeaters_by_level AS
SELECT emis_id, year, 0 as education_level_id, gender_id, SUM(qty) as qty
FROM enrolment_repeaters WHERE grade_id IN (1,2,3)
GROUP BY emis_id, year, gender_id
UNION
SELECT emis_id, year, 1 as education_level_id, gender_id, SUM(qty) as qty
FROM enrolment_repeaters WHERE grade_id IN (4,5,6,7,8,9,10)
GROUP BY emis_id, year, gender_id
UNION
SELECT emis_id, year, 2 as education_level_id, gender_id, SUM(qty) as qty
FROM enrolment_repeaters WHERE grade_id IN (11,12,13,14,15,16)
GROUP BY emis_id, year, gender_id;
DROP VIEW IF EXISTS enrolment_dropouts_by_level;
CREATE VIEW enrolment_dropouts_by_level AS
SELECT emis_id, year, 0 as education_level_id, gender_id, SUM(qty) as qty
FROM enrolment_dropouts WHERE grade_id IN (1,2,3)
GROUP BY emis_id, year, gender_id
UNION
SELECT emis_id, year, 1 as education_level_id, gender_id, SUM(qty) as qty
FROM enrolment_dropouts WHERE grade_id IN (4,5,6,7,8,9,10)
GROUP BY emis_id, year, gender_id
UNION
SELECT emis_id, year, 2 as education_level_id, gender_id, SUM(qty) as qty
FROM enrolment_dropouts WHERE grade_id IN (11,12,13,14,15,16)
GROUP BY emis_id, year, gender_id;
DROP TABLE IF EXISTS school_shifts;
CREATE TABLE school_shifts
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
education_level_id INTEGER NOT NULL,
shifts TINYINT NOT NULL
);
DROP VIEW IF EXISTS classrooms_functional;
CREATE VIEW classrooms_functional AS
SELECT c.emis_id, c.year, c.education_level_id, SUM(CASE WHEN shifts IS NULL THEN qty ELSE shifts * qty END) as classrooms_functional
FROM classrooms c
LEFT JOIN school_shifts s ON s.emis_id = c.emis_id AND s.education_level_id = c.education_level_id AND s.year = c.year
GROUP BY c.emis_id, c.year, c.education_level_id;
DROP VIEW IF EXISTS seats;
CREATE VIEW seats AS
SELECT f.emis_id, f.YEAR, f.education_level_id, SUM((CASE WHEN f.furniture_id IN (0, 1, 2) THEN f.furniture_id + 1 WHEN f.furniture_id = 3 THEN 1 ELSE 0 END)*f.qty) AS seats
FROM furnitures f
WHERE f.furniture_id IN (0, 1, 2, 3)
GROUP BY f.emis_id, f.education_level_id, f.YEAR
DROP VIEW IF EXISTS seats_functional;
CREATE VIEW seats_functional AS
SELECT s.emis_id, s.year, s.education_level_id, seats, CASE WHEN shifts IS NULL OR shifts = 0 THEN seats ELSE shifts * seats END as seats_functional
FROM seats s
LEFT JOIN school_shifts i ON s.emis_id = i.emis_id AND s.education_level_id = i.education_level_id AND s.year = i.year;
--
-- Facilities
--
DROP TABLE IF EXISTS school_facilities;
CREATE TABLE school_facilities
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
education_level_id TINYINT NOT NULL,
hasWater TINYINT,
hasPower TINYINT,
hasLibrary TINYINT,
hasLaboratory TINYINT,
hasFeeding TINYINT,
hasPlayground TINYINT
);
DROP VIEW IF EXISTS facilities;
CREATE VIEW facilities AS
(SELECT emis_id, year, education_level_id, 0 as facility, 1 as count FROM school_facilities WHERE hasWater = 1)
UNION
(SELECT emis_id, year, education_level_id, 1 as facility, 1 as count FROM school_facilities WHERE hasPower = 1)
UNION
(SELECT emis_id, year, education_level_id, 2 as facility, 1 as count FROM school_facilities WHERE hasLibrary = 1)
UNION
(SELECT emis_id, year, education_level_id, 3 as facility, 1 as count FROM school_facilities WHERE hasPlayground = 1)
UNION
(SELECT emis_id, year, education_level_id, 4 as facility, 1 as count FROM school_facilities WHERE hasLaboratory = 1)
UNION
(SELECT emis_id, year, education_level_id, 5 as facility, 1 as count FROM school_facilities WHERE hasFeeding = 1);
DROP VIEW IF EXISTS population_by_level;
CREATE VIEW population_by_level AS
SELECT district_id, year, gender_id, 0 as education_level_id, sum(qty) as qty
FROM population
WHERE age in (4, 5)
GROUP BY district_Id, year, gender_id
UNION
SELECT district_id, year, gender_id, 1 as education_level_id, sum(qty) as qty
FROM population
WHERE age in (6, 7, 8, 9, 10, 11)
GROUP BY district_Id, year, gender_id
UNION
SELECT district_id, year, gender_id, 2 as education_level_id, sum(qty) as qty
FROM population
WHERE age in (12, 13, 14, 15, 16, 17, 18)
GROUP BY district_Id, year, gender_id;
DROP VIEW IF EXISTS enrolment_net;
CREATE VIEW enrolment_net AS
SELECT emis_id, year, gender_id, 0 as education_level_id, sum(qty) as qty
FROM enrolment_ages
WHERE age in (4, 5)
GROUP BY emis_id, year, gender_id
UNION
SELECT emis_id, year, gender_id, 1 as education_level_id, sum(qty) as qty
FROM enrolment_ages
WHERE age in (6, 7, 8, 9, 10, 11)
GROUP BY emis_id, year, gender_id
UNION
SELECT emis_id, year, gender_id, 2 as education_level_id, sum(qty) as qty
FROM enrolment_ages
WHERE age in (12, 13, 14, 15, 16, 17, 18)
GROUP BY emis_id, year, gender_id;
-- **********************************
-- New Tables Oct 2018
-- **********************************
DROP TABLE if exists enrolment_disabilities_post2017;
CREATE TABLE enrolment_disabilities_post2017
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
education_level_id TINYINT NOT NULL,
grade_id TINYINT NOT NULL,
gender_id TINYINT NOT NULL,
disability_id TINYINT NOT NULL,
qty INTEGER NOT NULL
);
DROP VIEW IF EXISTS enrolment_disabilities;
CREATE VIEW enrolment_disabilities AS
SELECT emis_id, year, education_level_id, gender_id, disability_id, qty FROM enrolment_disabilities_pre2018
UNION
SELECT emis_id, year, education_level_id, gender_id, disability_id, SUM(qty) FROM enrolment_disabilities_post2017
GROUP BY emis_id, year, education_level_id, gender_id, disability_id;
ALTER TABLE enrolment_dropouts add column dropout_reason_id TINYINT NOT NULL;
Update enrolment_dropouts set dropout_reason_id = 12;
DROP TABLE if exists lookup_dropout_reasons;
CREATE TABLE lookup_dropout_reasons
(
dropout_reason_id TINYINT NOT NULL PRIMARY KEY,
dropout_reason_name CHAR(32) NOT NULL
);
DELETE FROM lookup_dropout_reasons;
INSERT INTO lookup_dropout_reasons VALUES
(1, "Parental abandonment"),
(2, "Domestic duties"),
(3, "No family support"),
(4, "Poverty"),
(5, "Marriage"),
(6, "Pregnacy"),
(7, "Death"),
(8, "Relocation"),
(9, "Employment"),
(10, "Explusion"),
(11, "Illness"),
(12, "Unknown");
DROP TABLE if exists expenses;
CREATE TABLE expenses
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
education_level_id TINYINT NOT NULL,
expense_id TINYINT NOT NULL,
amount integer NOT NULL);
DROP TABLE if exists lookup_expenses;
CREATE TABLE lookup_expenses
(expense_id TINYINT NOT NULL PRIMARY KEY,
expense_name CHAR(64) NOT NULL
);
DELETE FROM lookup_expenses;
INSERT INTO lookup_expenses VALUES
(1, "Mishahara"),
(2, "Vifaa vya kusomeshea na kujiunzia"),
(3, "Vifaa vya maabara"),
(4, "Vifaa vyengine"),
(5, "Gharama za maji, umeme na usafi"),
(6, "Usafiri"),
(7, "Ujenzi"),
(8, "Ziara za kimasomo"),
(9, "Michezo"),
(10, "Matumzi mengine");
DROP TABLE if exists revenues;
CREATE TABLE revenues
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
education_level_id TINYINT NOT NULL,
revenue_id TINYINT NOT NULL,
amount integer NOT NULL
);
DROP TABLE if exists lookup_revenues;
CREATE TABLE lookup_revenues
(
revenue_id TINYINT NOT NULL PRIMARY KEY,
revenue_name CHAR(64) NOT NULL
);
DELETE FROM lookup_revenues;
INSERT INTO lookup_revenues VALUES
(1, "Kilimo"),
(2, "Biashara ndogo ndogo "),
(3, "Kazi za mikono"),
(4, "Kodi ya jengo"),
(5, "Ada ya masomo"),
(6, "Misada ya nje"),
(7, "Ruzuku ya jengo"),
(8, "Misada isiyokuwa ya fedha"),
(9, "Michango ya wazee"),
(10, "Michango mengine");
DROP TABLE if exists lookup_other_tlms;
CREATE TABLE lookup_other_tlms
(
other_tlms_id TINYINT NOT NULL PRIMARY KEY,
other_tlms_name CHAR(64) NOT NULL
);
DELETE FROM lookup_other_tlms;
INSERT INTO lookup_other_tlms VALUES
(1, "Taipu"),
(2, "Atlas"),
(3, "Kamusi"),
(4, "Geometric sets"),
(5, "Globe"),
(6, "Projector"),
(7, "Fotokopi"),
(8, "Printa"),
(9, "Redio"),
(10, "Scanner"),
(11, "TV"),
(12, "Video"),
(13, "Chati za ukutani"),
(14, "Kompyuta za wanafunzi"),
(15, "Kompyuta za walimu"),
(18, "Science kit"),
(17, "Ramani za ukutani"),
(16, "Braille machine"),
(22, "Physics Kit"),
(21, "Biology Kit"),
(20, "Chemistry Kit"),
(19, "Physical education kit"),
(23, "Standard I Leveled Readers"),
(24, "Standard II Leveled Readers"),
(25, "Standard III Non-Fiction Readers"),
(26, "Standard IV Non-Fiction Readers");
DROP TABLE if exists other_tlms;
CREATE TABLE other_tlms
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
education_level_id TINYINT NOT NULL,
other_tlms_id TINYINT NOT NULL,
qty integer NOT NULL
);
DROP TABLE if exists lookup_shifts;
CREATE TABLE lookup_shifts
(
shift_id TINYINT NOT NULL PRIMARY KEY,
shift_name CHAR(64) NOT NULL
);
DELETE FROM lookup_shifts;
INSERT INTO lookup_shifts VALUES
(1, "Morning"),
(2, "Afternoon");
DROP TABLE if exists streams;
CREATE TABLE streams
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
grade_id TINYINT NOT NULL,
shift_id TINYINT NOT NULL,
qty TINYINT NOT NULL
);
DROP TABLE if exists teacher_guides;
CREATE TABLE teacher_guides
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
grade_id TINYINT NOT NULL,
subject_id INTEGER NOT NULL,
qty integer NOT NULL
);
DROP TABLE if exists lookup_teacher_age;
CREATE TABLE lookup_teacher_age
(
teacher_age_id TINYINT NOT NULL PRIMARY KEY,
teacher_age CHAR(32) NOT NULL
);
DELETE FROM lookup_teacher_age;
INSERT INTO lookup_teacher_age VALUES
(0, "Chini ya miaka 21"),
(1, "21-25"),
(2, "26-30"),
(3, "31-35"),
(4, "36-40"),
(5, "41-45"),
(6, "46-50"),
(7, "51-55"),
(8, "56-60"),
(9, "Zaidi ya miaka 60");
DROP TABLE if exists teacher_age;
CREATE TABLE teacher_age
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
education_level_id TINYINT NOT NULL,
gender_id TINYINT NOT NULL,
teacher_age_id INTEGER NOT NULL,
qty integer NOT NULL
);
DROP TABLE if exists lookup_teacher_duties;
CREATE TABLE lookup_teacher_duties
(
teacher_duties_id TINYINT NOT NULL PRIMARY KEY,
teacher_duties CHAR(32) NOT NULL
);
DELETE FROM lookup_teacher_duties;
INSERT INTO lookup_teacher_duties VALUES
(1, "Karani"),
(2, "Mpiga chapa"),
(3, "Mkutubi"),
(4, "Mlinzi"),
(5, "Mpishi"),
(6, "Dereva"),
(7, "Utingo"),
(8, "Fundi"),
(9, "Matron"),
(11, "Mshauri nasaha"),
(12, "Barsar"),
(13, "Afisa nidhame"),
(14, "Msidizi wa maabara"),
(10, "Mengineyo");
DROP TABLE IF EXISTS teacher_duties;
CREATE TABLE teacher_duties
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
education_level_id TINYINT NOT NULL,
gender_id TINYINT NOT NULL,
teacher_education_id TINYINT NOT NULL,
teacher_duties_id INTEGER NOT NULL,
qty integer NOT NULL
);
DROP TABLE IF EXISTS lookup_ppe_status;
CREATE TABLE lookup_ppe_status
(
ppe_status_id tinyint(4) NOT NULL,
ppe_status char(32) NOT NULL
);
DELETE FROM lookup_ppe_status;
INSERT INTO lookup_ppe_status VALUES
(1, "With PPE"),
(2, "Without PPE");
DROP Table IF EXISTS lookup_teacher_age;
CREATE TABLE lookup_teacher_age
(
teacher_age_id tinyint(4) NOT NULL,
teacher_age char(32) NOT NULL
);
DELETE FROM lookup_teacher_age;
INSERT INTO lookup_teacher_age VALUES
(0, "Chini ya miaka 21"),
(1, "21-25"),
(2, "26-30"),
(3, "31-35"),
(4, "36-40"),
(5, "41-45"),
(6, "46-50"),
(7, "51-55"),
(8, "56-60"),
(9, "Zaidi ya miaka 60");
DROP Table IF EXISTS teacher_multilevels_post2017;
CREATE TABLE teacher_multilevels_post2017
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
education_level_id TINYINT NOT NULL,
gender_id TINYINT NOT NULL,
teacher_trained_id TINYINT NOT NULL,
teacher_education_id TINYINT NOT NULL,
qty integer NOT NULL
);
DROP VIEW IF EXISTS teacher_multilevels;
CREATE VIEW teacher_multilevels AS
SELECT emis_id, year, education_level_id, gender_id, teacher_edu_condensed_id, qty FROM teacher_multilevels_pre2018
UNION
SELECT emis_id, year, education_level_id, gender_id, 0 as teacher_edu_condensed_id, qty FROM teacher_multilevels_post2017 WHERE teacher_education_id = 0
UNION
(SELECT emis_id, year, education_level_id, gender_id, 1 as teacher_edu_condensed_id, SUM(qty) as qty FROM teacher_multilevels_post2017 WHERE teacher_education_id IN (1, 2, 3)
GROUP BY emis_id, year, education_level_id, gender_id)
UNION
SELECT emis_id, year, education_level_id, gender_id, teacher_education_id - 2 as teacher_edu_condensed_id, qty FROM teacher_multilevels_post2017 WHERE teacher_education_id IN (4, 5);
DROP TABLE IF EXISTS school_infos;
CREATE TABLE school_infos
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
shared_building TINYINT,
distance_road FLOAT,
registration_no VARCHAR(32),
year_established INTEGER,
location_id TINYINT,
school_owner_id TINYINT,
telephone CHAR(12),
email VARCHAR(64),
loi_kiswahili TINYINT,
loi_english TINYINT,
loi_other TINYINT,
stats_name VARCHAR(100),
stats_telephone CHAR(32),
HT_name VARCHAR(100),
head_gender_id TINYINT,
HT_telephone CHAR(32)
);
DROP TABLE IF EXISTS lookup_school_owner;
CREATE TABLE lookup_school_owner
(
school_owner_id TINYINT NOT NULL PRIMARY KEY,
school_owner_name CHAR(32) NOT NULL
);
DELETE FROM lookup_school_owner;
INSERT INTO lookup_school_owner VALUES
(1, "Serikali"),
(2, "Jamil"),
(3, "Mtu Binafisi"),
(4, "Jumiya isiyo ya kiserikali"),
(5, "Mashirika")
;
DROP TABLE IF EXISTS lookup_location;
CREATE TABLE lookup_location
(
location_id TINYINT NOT NULL PRIMARY KEY,
location_name CHAR(32) NOT NULL
);
DELETE FROM lookup_location;
INSERT INTO lookup_location VALUES
(1, "Urban"),
(2, "Rural")
;
-- *******
-- jorg --
-- *******
--
-- Power
--
DROP TABLE IF EXISTS school_power;
CREATE TABLE school_power
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
education_level_id TINYINT NOT NULL,
power_id TINYINT
);
DROP TABLE IF EXISTS lookup_power;
CREATE TABLE lookup_power
(
power_id TINYINT NOT NULL PRIMARY KEY,
power_name CHAR(32) NOT NULL
);
DELETE FROM lookup_power;
INSERT INTO lookup_power VALUES
(1, "Grid"),
(2, "Other");
--
-- Waters
--
DROP TABLE IF EXISTS school_water;
CREATE TABLE school_water
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
education_level_id TINYINT NOT NULL,
water_id TINYINT NOT NULL
);
DROP TABLE IF EXISTS lookup_water;
CREATE TABLE lookup_water
(
water_id TINYINT NOT NULL PRIMARY KEY,
water_name CHAR(32) NOT NULL
);
DELETE FROM lookup_water;
INSERT INTO lookup_water VALUES
(1, "Tap"),
(2, "waters Pump"),
(3, "Protected Well"),
(4, "Unprotected Well"),
(5, "Other");
--
-- Teacher_housing
--
DROP TABLE IF EXISTS school_teacher_housing;
CREATE TABLE school_teacher_housing
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
education_level_id TINYINT NOT NULL,
houses_qty INTEGER,
teachers_housed INTEGER
);
--
--
-- Buildings
--
DROP TABLE IF EXISTS school_buildings;
CREATE TABLE school_buildings
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
education_level_id TINYINT NOT NULL,
building_id TINYINT NOT NULL,
qty INTEGER
);
DROP TABLE IF EXISTS lookup_buildings;
CREATE TABLE lookup_buildings
(
buildings_id TINYINT NOT NULL PRIMARY KEY,
buildings_name CHAR(32) NOT NULL
);
DELETE FROM lookup_buildings;
INSERT INTO lookup_buildings VALUES
(0, "Ukumbi"),
(4, "Mkahawa"),
(1, "Jiko"),
(5, "Dakhalia W'me"),
(6, "Dakhalia W'ke"),
(2, "Ghala"),
(3, "Duka");
--
--
-- OtherRooms
--
DROP TABLE IF EXISTS other_rooms;
CREATE TABLE other_rooms
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
education_level_id TINYINT NOT NULL,
other_room_id TINYINT NOT NULL,
qty INTEGER
);
DROP TABLE IF EXISTS lookup_other_rooms;
CREATE TABLE lookup_other_rooms
(
other_rooms_id TINYINT NOT NULL PRIMARY KEY,
other_rooms_name CHAR(32) NOT NULL
);
DELETE FROM lookup_other_rooms;
INSERT INTO lookup_other_rooms VALUES
(0, "Maktaba"),
(1, "Afisi ya Mwalimu Mkuu"),
(2, "Afisi za Walimu"),
(3, "Ukumbi ya kusoma"),
(4, "Chumba cha Kompyuta"),
(5, "Chumba cha Ushauri Nasaha"),
(6, "Vyumba vyengine"),
(7, "Maabara"),
(8, "Karakana ya ufundi"),
(9, "Chumba cha jiografia");
--
-- teacher_subject_specialization
--
DROP TABLE IF EXISTS teacher_subject_specializations;
CREATE TABLE teacher_subject_specializations
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
education_level_id TINYINT NOT NULL,
subject_id TINYINT NOT NULL,
subject_specialization_qualification TINYINT NOT NULL,
gender_id TINYINT NOT NULL,
qty INTEGER NOT NULL
);
DROP TABLE IF EXISTS lookup_subject_specialization_qualifications;
CREATE TABLE lookup_subject_specialization_qualifications
(
subject_specialization_qualifications_id TINYINT NOT NULL PRIMARY KEY,
subject_specialization_qualifications_name CHAR(32) NOT NULL
);
DELETE FROM lookup_subject_specialization_qualifications;
INSERT INTO lookup_subject_specialization_qualifications VALUES
(1, "Cheti"),
(2, "Stashahada (Diploma)"),
(3, "Shahada ya kwanz"),
(4, "Shahada ya Uzamili"),
(5, "Shahada ya Uzamivu");
--
-- enrolment_transout
--
DROP TABLE IF EXISTS enrolment_transout;
CREATE TABLE enrolment_transout
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
gender_id TINYINT NOT NULL,
grade_id TINYINT NOT NULL,
qty INTEGER NOT NULL
);
--
-- enrolment_transin
--
DROP TABLE IF EXISTS enrolment_transin;
CREATE TABLE enrolment_transin
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
gender_id TINYINT NOT NULL,
grade_id TINYINT NOT NULL,
qty INTEGER NOT NULL
);
--
-- enrolment_streetkids
--
DROP TABLE IF EXISTS enrolment_streetkids;
CREATE TABLE enrolment_streetkids
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
gender_id TINYINT NOT NULL,
grade_id TINYINT NOT NULL,
qty INTEGER NOT NULL
);
--
-- enrolment_orphans
--
DROP TABLE IF EXISTS enrolment_orphans;
CREATE TABLE enrolment_orphans
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
gender_id TINYINT NOT NULL,
grade_id TINYINT NOT NULL,
qty INTEGER NOT NULL
);
--
-- teacher_skills
--
DROP TABLE IF EXISTS teacher_skills;
CREATE TABLE teacher_skills
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
education_level_id TINYINT NOT NULL,
gender_id TINYINT NOT NULL,
teacher_skills_id TINYINT NOT NULL,
qty INTEGER NOT NULL
);
DROP TABLE IF EXISTS lookup_teacher_skills;
CREATE TABLE lookup_teacher_skills
(
teacher_skills_id TINYINT NOT NULL PRIMARY KEY,
teacher_skills_name CHAR(32) NOT NULL
);
DELETE FROM lookup_teacher_skills;
INSERT INTO lookup_teacher_skills VALUES
(1, "Computer"),
(2, "Life Skills"),
(3, "HIV/AIDS"),
(4, "School Development"),
(5, "Language and English"),
(8, "ECD/Pre-1"),
(6, "Integrated Education"),
(7, "Special Education"),
(9, "Alternative Learning");
--
-- teacher_leave
--
DROP TABLE IF EXISTS teacher_leaves;
CREATE TABLE teacher_leaves
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
education_level_id TINYINT NOT NULL,
gender_id TINYINT NOT NULL,
teacher_edu_condensed_id TINYINT NOT NULL,
teacher_leave_id TINYINT NOT NULL,
qty INTEGER NOT NULL
);
CREATE TABLE lookup_teacher_leave_reasons
(
teacher_leave_reason_id TINYINT NOT NULL PRIMARY KEY,
teacher_leave_reason_name CHAR(32) NOT NULL
);
DELETE FROM lookup_teacher_leave_reasons;
INSERT INTO lookup_teacher_leave_reasons VALUES
(1, "discharged"),
(2, "retired"),
(3, "death"),
(4, "illness"),
(5, "paid vacation"),
(6, "transfer to government office"),
(7, "transfer to private organization"),
(8, "training"),
(9, "disability"),
(10, "Other");
--
-- teacher_inset
--
DROP TABLE IF EXISTS teacher_insets;
CREATE TABLE teacher_insets
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
education_level_id TINYINT NOT NULL,
gender_id TINYINT NOT NULL,
teacher_inset_id TINYINT NOT NULL,
teacher_trained_id TINYINT NOT NULL,
qty INTEGER NOT NULL
);
DROP TABLE IF EXISTS lookup_teacher_trained;
CREATE TABLE lookup_teacher_trained
(
teacher_trained_id TINYINT NOT NULL PRIMARY KEY,
teacher_trained_name CHAR(32) NOT NULL
);
DELETE FROM lookup_teacher_trained;
INSERT INTO lookup_teacher_trained VALUES
(1, "Trained"),
(2, "Untrained");
--
-- teacher_education
--
DROP TABLE IF EXISTS teacher_educations;
CREATE TABLE teacher_educations
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
education_level_id TINYINT NOT NULL,
gender_id TINYINT NOT NULL,
teacher_education_id TINYINT NOT NULL,
teacher_specialization_id TINYINT,
teacher_trained_id TINYINT NOT NULL,
qty INTEGER NOT NULL
);
DROP TABLE IF EXISTS teacher_educations_ss;
CREATE TABLE teacher_educations_ss
(
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
emis_id INTEGER NOT NULL,
year INTEGER NOT NULL,
education_level_id TINYINT NOT NULL,
gender_id TINYINT NOT NULL,
teacher_education_id TINYINT NOT NULL,
teacher_specialization_id TINYINT,
teacher_trained_id TINYINT NOT NULL,
qty INTEGER NOT NULL
);
DROP TABLE IF EXISTS lookup_teacher_specialization;
CREATE TABLE lookup_teacher_specialization
(
teacher_specialization_id TINYINT NOT NULL PRIMARY KEY,
teacher_specialization_name CHAR(32) NOT NULL
);
DELETE FROM lookup_teacher_specialization;
INSERT INTO lookup_teacher_specialization VALUES
(1, "Sanaa"),
(2, "Sayansi"),
(3, "Mchanganyiko");
DROP TABLE IF EXISTS lookup_age_type;
CREATE TABLE lookup_age_type
(
age_type_id TINYINT NOT NULL PRIMARY KEY,
age_type_name CHAR(32) NOT NULL
);
DELETE FROM lookup_age_type;
INSERT INTO lookup_age_type VALUES
(0, "Under age"),
(1, "Correct age"),
(2, "Over age");
DROP VIEW IF EXISTS enrolment_age_type_by_grade;
CREATE VIEW enrolment_age_type_by_grade AS
SELECT emis_id, year, e.grade_id as grade_id, gender_id, IF(e.age < g.age, 0, IF(e.age > g.age, 2, 1)) as age_type, sum(qty) as qty
FROM enrolment_ages e
INNER JOIN lookup_grades g ON g.grade_id = e.grade_id
GROUP BY emis_id, year, grade_id, gender_id, age_type
HAVING qty > 0;
DROP VIEW IF EXISTS enrolment_age_type_by_level;
CREATE VIEW enrolment_age_type_by_level AS
SELECT emis_id, year, e.education_level_id as education_level_id, gender_id, IF(e.age < l.min_age, 0, IF(e.age > l.max_age, 2, 1)) as age_type, sum(qty) as qty
FROM enrolment_ages e
INNER JOIN lookup_education_levels l ON l.education_level_id = e.education_level_id
GROUP BY emis_id, year, education_level_id, gender_id, age_type
HAVING qty > 0;
DROP VIEW IF EXISTS enrolment_ss_age_type_by_grade;
CREATE VIEW enrolment_ss_age_type_by_grade AS
SELECT emis_id, year, e.grade_id as grade_id, gender_id, IF(e.age < g.age, 0, IF(e.age > g.age, 2, 1)) as age_type, sum(qty) as qty
FROM enrolment_ages_ss e
INNER JOIN lookup_grades g ON g.grade_id = e.grade_id
GROUP BY emis_id, year, grade_id, gender_id, age_type
HAVING qty > 0;
DROP VIEW IF EXISTS enrolment_ss_age_type_by_level;
CREATE VIEW enrolment_ss_age_type_by_level AS
SELECT emis_id, year, e.education_level_id as education_level_id, gender_id, IF(e.age < l.min_age, 0, IF(e.age > l.max_age, 2, 1)) as age_type, sum(qty) as qty
FROM enrolment_ages_ss e
INNER JOIN lookup_education_levels l ON l.education_level_id = e.education_level_id
GROUP BY emis_id, year, education_level_id, gender_id, age_type
HAVING qty > 0;
DROP VIEW IF EXISTS schools_district_hierarchy;
CREATE VIEW schools_district_hierarchy AS
SELECT emis_id, year, district_id
FROM schools_shehia_hierarchy_by_year sch
INNER JOIN shehias s ON s.shehia_id = sch.shehia_id
INNER JOIN wards w ON w.ward_id = s.ward_id
INNER JOIN constituencies c ON c.constituency_id = w.constituency_id;
DROP VIEW IF EXISTS school_active_shifts;
CREATE VIEW school_active_shifts AS
SELECT sl.emis_id, sl.year, sl.education_level_id, IF(s.shifts IS NULL, 1, s.shifts) as shifts
FROM schools_active_by_level sl
LEFT JOIN school_shifts s ON sl.emis_id = s.emis_id AND sl.year = s.year AND sl.education_level_id = s.education_level_id;
--- COMPUTERS ---
DROP VIEW IF EXISTS computers;
CREATE VIEW computers AS
(SELECT t.emis_id, t.year, t.education_level_id, SUM(qty) as qty, SUM(CASE WHEN shifts IS NULL THEN qty ELSE shifts * qty END) as computers_functional
FROM other_tlms t
LEFT JOIN school_shifts s ON s.emis_id = t.emis_id AND s.education_level_id = t.education_level_id AND s.year = t.year
WHERE other_tlms_id = 14
GROUP BY t.emis_id, t.year, t.education_level_id);
--- lookup_ages ---
DROP TABLE IF EXISTS lookup_ages;
CREATE TABLE lookup_ages
(
age_id TINYINT NOT NULL PRIMARY KEY,
age TINYINT NOT NULL,
age_name CHAR(32) NOT NULL,
education_level_id TINYINT NOT NULL
);
INSERT INTO lookup_ages VALUES
(0, 3, "Age 3", 0),
(1, 4, "Age 4", 0),
(2, 5, "Age 5", 0),
(3, 6, "Age 6", 0),
(4, 7, "7 na Zaidi", 0),
(5, 5, "Chinya ya 6", 1),
(6, 6, "Age 6", 1),
(7, 7, "Age 7", 1),
(8, 8, "Age 8", 1),
(9, 9, "Age 9", 1),
(10, 10, "Age 10", 1),
(11, 11, "Age 11", 1),
(12, 12, "Age 12", 1),
(13, 13, "Age 13", 1),
(14, 14, "Age 14", 1),
(15, 15, "Zaidi ya 14", 1),
(16, 11, "Chinya ya 12", 2),
(17, 12, "Age 12", 2),
(18, 13, "Age 13", 2),
(19, 14, "Age 14", 2),
(20, 15, "Age 15", 2),
(21, 16, "Age 16", 2),
(22, 17, "Age 17", 2),
(23, 18, "Age 18", 2),
(24, 19, "Age 19", 2),
(25, 20, "Zaidi ya 19", 2);
DROP TABLE IF EXISTS lookup_ages_entrants;
CREATE TABLE lookup_ages_entrants
(
age_entrants_id TINYINT NOT NULL PRIMARY KEY,
age TINYINT NOT NULL,
age_name CHAR(32) NOT NULL,
education_level_id TINYINT NOT NULL
);
INSERT INTO lookup_ages_entrants VALUES
(0, 5, "Chinya ya 6", 1),
(1, 6, "Age 6", 1),
(2, 7, "Age 7", 1),
(3, 8, "Age 8", 1),
(4, 9, "Age 9", 1),
(5, 10, "Age 10", 1),
(6, 11, "Zaidi ya 10", 1);
|
insert into orders(user_id)
values ($1)
RETURNING *;
|
insert into exchange_value(id,currency_from,currency_to,conversion_multiple,port)
values(10001,'USD','PKR',65,0);
insert into exchange_value(id,currency_from,currency_to,conversion_multiple,port)
values(10002,'EUR','PKR',75,0);
insert into exchange_value(id,currency_from,currency_to,conversion_multiple,port)
values(10003,'AUD','PKR',25,0); |
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL';
CREATE SCHEMA IF NOT EXISTS `contabilidadGrupo2` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci ;
USE `contabilidadGrupo2`;
-- -----------------------------------------------------
-- Table `contabilidadGrupo2`.`ASIENTO`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `contabilidadGrupo2`.`ASIENTO` ;
CREATE TABLE IF NOT EXISTS `contabilidadGrupo2`.`ASIENTO` (
`num` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
`fecha` DATE NOT NULL ,
PRIMARY KEY (`num`) )
ENGINE = InnoDB
PACK_KEYS = DEFAULT;
-- -----------------------------------------------------
-- Table `contabilidadGrupo2`.`CUENTA`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `contabilidadGrupo2`.`CUENTA` ;
CREATE TABLE IF NOT EXISTS `contabilidadGrupo2`.`CUENTA` (
`num` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
`tipo` VARCHAR(1) NOT NULL ,
`nombre` VARCHAR(45) NOT NULL ,
`descripcion` VARCHAR(200) NULL ,
PRIMARY KEY (`num`) )
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `contabilidadGrupo2`.`CLIENTE`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `contabilidadGrupo2`.`CLIENTE` ;
CREATE TABLE IF NOT EXISTS `contabilidadGrupo2`.`CLIENTE` (
`rif` VARCHAR(20) NOT NULL ,
`nombre` VARCHAR(45) NOT NULL ,
PRIMARY KEY (`rif`) )
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `contabilidadGrupo2`.`PRODUCTO`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `contabilidadGrupo2`.`PRODUCTO` ;
CREATE TABLE IF NOT EXISTS `contabilidadGrupo2`.`PRODUCTO` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
`nombre` VARCHAR(45) NOT NULL ,
`costo_unitario` FLOAT UNSIGNED NOT NULL ,
PRIMARY KEY (`id`) )
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `contabilidadGrupo2`.`VENTA`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `contabilidadGrupo2`.`VENTA` ;
CREATE TABLE IF NOT EXISTS `contabilidadGrupo2`.`VENTA` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
`CLIENTE_rif` VARCHAR(20) NOT NULL ,
`PRODUCTO_id` INT UNSIGNED NOT NULL ,
`fecha` DATE NOT NULL ,
`costo_unitario` FLOAT NOT NULL ,
`cantidad` INT UNSIGNED NOT NULL DEFAULT 0 ,
PRIMARY KEY (`id`, `CLIENTE_rif`, `PRODUCTO_id`) ,
INDEX `fk_CLIENTE_has_PRODUCTO_CLIENTE` (`CLIENTE_rif` ASC) ,
INDEX `fk_CLIENTE_has_PRODUCTO_PRODUCTO` (`PRODUCTO_id` ASC) ,
CONSTRAINT `fk_CLIENTE_has_PRODUCTO_CLIENTE`
FOREIGN KEY (`CLIENTE_rif` )
REFERENCES `contabilidadGrupo2`.`CLIENTE` (`rif` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_CLIENTE_has_PRODUCTO_PRODUCTO`
FOREIGN KEY (`PRODUCTO_id` )
REFERENCES `contabilidadGrupo2`.`PRODUCTO` (`id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `contabilidadGrupo2`.`PROVEEDOR`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `contabilidadGrupo2`.`PROVEEDOR` ;
CREATE TABLE IF NOT EXISTS `contabilidadGrupo2`.`PROVEEDOR` (
`rif` VARCHAR(20) NOT NULL ,
`nombre` VARCHAR(45) NOT NULL ,
PRIMARY KEY (`rif`) )
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `contabilidadGrupo2`.`COMPRA`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `contabilidadGrupo2`.`COMPRA` ;
CREATE TABLE IF NOT EXISTS `contabilidadGrupo2`.`COMPRA` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
`PRODUCTO_id` INT UNSIGNED NOT NULL ,
`PROVEEDOR_rif` VARCHAR(20) NOT NULL ,
`fecha` DATE NOT NULL ,
`costo_unitario` FLOAT NOT NULL ,
`cantidad` INT UNSIGNED NOT NULL DEFAULT 0 ,
PRIMARY KEY (`id`, `PRODUCTO_id`, `PROVEEDOR_rif`) ,
INDEX `fk_PRODUCTO_has_PROVEEDOR_PRODUCTO` (`PRODUCTO_id` ASC) ,
INDEX `fk_PRODUCTO_has_PROVEEDOR_PROVEEDOR` (`PROVEEDOR_rif` ASC) ,
CONSTRAINT `fk_PRODUCTO_has_PROVEEDOR_PRODUCTO`
FOREIGN KEY (`PRODUCTO_id` )
REFERENCES `contabilidadGrupo2`.`PRODUCTO` (`id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_PRODUCTO_has_PROVEEDOR_PROVEEDOR`
FOREIGN KEY (`PROVEEDOR_rif` )
REFERENCES `contabilidadGrupo2`.`PROVEEDOR` (`rif` )
ON DELETE NO ACTION
ON UPDATE NO ACTION);
-- -----------------------------------------------------
-- Table `contabilidadGrupo2`.`REGISTRO`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `contabilidadGrupo2`.`REGISTRO` ;
CREATE TABLE IF NOT EXISTS `contabilidadGrupo2`.`REGISTRO` (
`ASIENTO_num` INT UNSIGNED NOT NULL ,
`CUENTA_num` INT UNSIGNED NOT NULL ,
`debe` FLOAT NULL ,
`haber` FLOAT NULL ,
`VENTA_id` INT UNSIGNED NULL ,
`VENTA_CLIENTE_rif` VARCHAR(20) NULL ,
`VENTA_PRODUCTO_id` INT UNSIGNED NULL ,
`COMPRA_id` INT UNSIGNED NULL ,
`COMPRA_PRODUCTO_id` INT UNSIGNED NULL ,
`COMPRA_PROVEEDOR_rif` VARCHAR(20) NULL ,
`tipo` VARCHAR(1) NOT NULL ,
PRIMARY KEY (`ASIENTO_num`, `CUENTA_num`) ,
INDEX `fk_ASIENTO_has_CUENTA_ASIENTO` (`ASIENTO_num` ASC) ,
INDEX `fk_ASIENTO_has_CUENTA_CUENTA` (`CUENTA_num` ASC) ,
INDEX `fk_REGISTRO_VENTA` (`VENTA_id` ASC, `VENTA_CLIENTE_rif` ASC, `VENTA_PRODUCTO_id` ASC) ,
INDEX `fk_REGISTRO_COMPRA` (`COMPRA_id` ASC, `COMPRA_PRODUCTO_id` ASC, `COMPRA_PROVEEDOR_rif` ASC) ,
CONSTRAINT `fk_ASIENTO_has_CUENTA_ASIENTO`
FOREIGN KEY (`ASIENTO_num` )
REFERENCES `contabilidadGrupo2`.`ASIENTO` (`num` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_ASIENTO_has_CUENTA_CUENTA`
FOREIGN KEY (`CUENTA_num` )
REFERENCES `contabilidadGrupo2`.`CUENTA` (`num` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_REGISTRO_VENTA`
FOREIGN KEY (`VENTA_id` , `VENTA_CLIENTE_rif` , `VENTA_PRODUCTO_id` )
REFERENCES `contabilidadGrupo2`.`VENTA` (`id` , `CLIENTE_rif` , `PRODUCTO_id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_REGISTRO_COMPRA`
FOREIGN KEY (`COMPRA_id` , `COMPRA_PRODUCTO_id` , `COMPRA_PROVEEDOR_rif` )
REFERENCES `contabilidadGrupo2`.`COMPRA` (`id` , `PRODUCTO_id` , `PROVEEDOR_rif` )
ON DELETE NO ACTION
ON UPDATE NO ACTION);
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
|
# Initial
# --- !Ups
CREATE TABLE "responses" (
"id" SERIAL UNIQUE,
"name" VARCHAR(64) NOT NULL,
"response" TEXT NOT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "products" (
"id" SERIAL UNIQUE,
"short_name" VARCHAR(16) UNIQUE,
"name" VARCHAR(255),
PRIMARY KEY ("id")
);
CREATE TABLE "pings" (
"id" SERIAL UNIQUE,
"product" VARCHAR(255) NOT NULL REFERENCES "products" ("short_name"),
"license" VARCHAR(255) NOT NULL,
"user_name" VARCHAR(64) NOT NULL,
"date" TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
"response_id" INT DEFAULT NULL REFERENCES "responses" ("id"),
"ip" VARCHAR(16) DEFAULT '0.0.0.0',
PRIMARY KEY ("id")
);
CREATE TABLE "pingresponses" (
"id" SERIAL UNIQUE,
"product_id" INT,
"license" VARCHAR(255),
"user_name" VARCHAR(64),
"response_id" INT REFERENCES "responses" ("id"),
PRIMARY KEY ("id")
);
CREATE UNIQUE INDEX ping_userlicprod ON "pingresponses" ("product_id", "license", "user_name");
CREATE TABLE "pingextras" (
"ping_id" INT REFERENCES "pings" ("id") ON DELETE CASCADE,
"key" VARCHAR(16) NOT NULL,
"value" TEXT NOT NULL,
PRIMARY KEY ("ping_id", "key")
);
CREATE INDEX pingextra_id ON "pingextras" ("ping_id");
# --- !Downs
DROP TABLE "products";
DROP TABLE "pings";
DROP TABLE "responses";
DROP TABLE "pingresponses";
DROP TABLE "pingextras"; |
CREATE DATABASE chat;
USE chat;
-- CREATE TABLE messages (
-- Describe your table here.
-- );
/* Create other tables and define schemas for them here! */
-- ---
-- Globals
-- ---
-- SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
-- SET FOREIGN_KEY_CHECKS=0;
-- ---
-- Table 'Messages'all
--
-- ---
DROP TABLE IF EXISTS `Messages`;
CREATE TABLE `Messages` (
`id` INTEGER NULL AUTO_INCREMENT DEFAULT NULL,
`user_id` INTEGER(11) NOT NULL,
`room_id` INTEGER(11) NOT NULL,
`text` MEDIUMTEXT NOT NULL,
`username` VARCHAR(255) NOT NULL,
`roomname` VARCHAR(255) NOT NULL,
`created_at` TIMESTAMP NOT NULL,
`updated_at` TIMESTAMP NOT NULL,
PRIMARY KEY (`id`)
);
-- ---
-- Table 'Rooms'
--
-- ---
DROP TABLE IF EXISTS `Rooms`;
CREATE TABLE `Rooms` (
`id` INTEGER NULL AUTO_INCREMENT DEFAULT NULL,
`user_id` INTEGER(11) NOT NULL,
`users_count` INTEGER(11) NOT NULL DEFAULT 0,
`roomname` VARCHAR(255) NOT NULL,
`created_at` TIMESTAMP NOT NULL,
`updated_at` TIMESTAMP NOT NULL,
PRIMARY KEY (`id`)
);
-- ---
-- Table 'Users'
--
-- ---
DROP TABLE IF EXISTS `Users`;
CREATE TABLE `Users` (
`id` INTEGER NULL AUTO_INCREMENT DEFAULT NULL,
`curr_room_id` INTEGER(11) NOT NULL,
`username` VARCHAR(255) NOT NULL,
`created_at` TIMESTAMP NOT NULL,
`updated_at` TIMESTAMP NOT NULL,
PRIMARY KEY (`id`)
);
-- ---
-- Foreign Keys
-- ---
-- ---
-- Table Properties
-- ---
-- ALTER TABLE `Messages` ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- ALTER TABLE `Rooms` ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- ALTER TABLE `Users` ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- ---
-- Test Data
-- ---
-- INSERT INTO `Messages` (`id`,`user_id`,`room_id`,`text`,`username`,`roomname`,`created_at`,`updated_at`) VALUES
-- ('','','','','','','','');
-- INSERT INTO `Rooms` (`id`,`user_id`,`users_count`,`roomname`,`created_at`,`updated_at`) VALUES
-- ('','','','','','');
-- INSERT INTO `Users` (`id`,`curr_room_id`,`username`,`created_at`,`updated_at`) VALUES
-- ('','','','','');
/* Execute this file from the command line by typing:
* mysql < schema.sql
* to create the database and the tables.*/
|
CREATE DATABASE IF NOT EXISTS data_hub DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
use data_hub;
CREATE TABLE `task` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键'
, `task_key` varchar(50) NOT NULL COMMENT '任务编号'
, `task_name` varchar(50) NOT NULL COMMENT '任务编号'
, `jar_path` text NOT NULL COMMENT '运行的fatjar所在全路径'
, `transform_sql` text DEFAULT NULL COMMENT 'etl的sql'
, `hive_support` int(2) DEFAULT NULL COMMENT '是否需要读取或者写hive表 1:需要;2:不需要'
, `spark_config` text DEFAULT NULL COMMENT 'sparky运行参数配置'
, `latch` int(2) DEFAULT NULL COMMENT '是否执行该任务的开关 1:执行;2:跳过'
, `created` datetime NOT NULL COMMENT '创建日期'
, `modified` datetime NOT NULL COMMENT '修改时间'
, `yn` int(2) DEFAULT 1 COMMENT '是否有效'
, PRIMARY KEY (`id`)
, unique key `id_unique` (`id`)
, unique key `task_key_unique` (`task_key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='任务表';
CREATE TABLE `source` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键'
, `task_id` bigint(20) NOT NULL COMMENT '任务id'
, `temp_view_name` varchar(50) NOT NULL COMMENT 'spark临时表的表名'
, `source_type` varchar(200) DEFAULT NULL COMMENT '数据源类的全限定名'
, `source_config_type` varchar(200) DEFAULT NULL COMMENT '数据源config类的全限定名'
, `source_config_json` text DEFAULT NULL COMMENT 'source的配置,以json格式保存'
, `created` datetime NOT NULL COMMENT '创建日期'
, `modified` datetime NOT NULL COMMENT '修改时间'
, `yn` int(2) DEFAULT 1 COMMENT '是否有效'
, PRIMARY KEY (`id`)
, unique key `id_unique` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='数据源表';
CREATE TABLE `sink` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键'
, `task_id` bigint(20) NOT NULL COMMENT '任务id'
, `sink_type` varchar(200) DEFAULT NULL COMMENT 'sink类的全限定名'
, `sink_config_type` varchar(200) DEFAULT NULL COMMENT 'sink的config类的全限定名'
, `sink_config_json` text DEFAULT NULL COMMENT 'sink的配置,以json格式保存'
, `created` datetime NOT NULL COMMENT '创建日期'
, `modified` datetime NOT NULL COMMENT '修改时间'
, `yn` int(2) DEFAULT 1 COMMENT '是否有效'
, PRIMARY KEY (`id`)
, unique key `id_unique` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='写数据器表';
CREATE TABLE `handle` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键'
, `task_id` bigint(20) NOT NULL COMMENT '任务id'
, `execute_type` int(2) NOT NULL COMMENT 'handle执行类型 1:前置;2:后置;3:异常'
, `handle_type` varchar(200) DEFAULT NULL COMMENT 'handle的全限定名'
, `handle_config_type` varchar(200) DEFAULT NULL COMMENT 'handle的config类的全限定名'
, `handle_config_json` text DEFAULT NULL COMMENT 'handle的配置,以json格式保存'
, `created` datetime NOT NULL COMMENT '创建日期'
, `modified` datetime NOT NULL COMMENT '修改时间'
, `yn` int(2) DEFAULT 1 COMMENT '是否有效'
, PRIMARY KEY (`id`)
, unique key `id_unique` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='handle处理表';
CREATE TABLE `task_log` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键'
, `task_key` varchar(50) NOT NULL COMMENT '任务编号'
, `start_time` datetime NOT NULL COMMENT '任务开始时间'
, `end_time` datetime NOT NULL COMMENT '任务结束时间'
, `status` int(2) NOT NULL COMMENT '运行状态'
, `error_log` text DEFAULT NULL COMMENT '运行日志记录'
, `created` datetime NOT NULL COMMENT '创建日期'
, `modified` datetime NOT NULL COMMENT '修改时间'
, `yn` int(2) DEFAULT 1 COMMENT '是否有效'
, PRIMARY KEY (`id`)
, unique key `id_unique` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='任务表运行日志表';
CREATE TABLE `test_student` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键'
, `student_id` bigint(20) NOT NULL COMMENT '学生编号'
, `student_name` varchar(20) NOT NULL COMMENT '学生姓名'
, `student_grade` varchar(10) NOT NULL COMMENT '学生姓名'
, `created` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建日期'
, `modified` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间'
, `yn` int(2) DEFAULT 1 COMMENT '是否有效'
, PRIMARY KEY (`id`)
, unique key `id_unique` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用于测试程序使用的表'; |
create table REPORT_GROUP (
ID varchar(32),
CREATE_TS datetime(3),
CREATED_BY varchar(50),
VERSION integer not null default 1,
UPDATE_TS datetime(3),
UPDATED_BY varchar(50),
DELETE_TS datetime(3),
DELETED_BY varchar(50),
DELETE_TS_NN datetime(3) not null default '1000-01-01 00:00:00.000',
SYS_TENANT_ID varchar(255),
SYS_TENANT_ID_NN varchar(255),
--
TITLE varchar(190) not null,
CODE varchar(255),
LOCALE_NAMES text,
--
primary key (ID)
)^
create unique index IDX_REPORT_GROUP_UNIQ_TITLE on REPORT_GROUP (TITLE, SYS_TENANT_ID_NN, DELETE_TS_NN)^
create trigger REPORT_GROUP_SYS_TENANT_ID_NN_INSERT_TRIGGER before insert on REPORT_GROUP
for each row set NEW.SYS_TENANT_ID_NN = if (NEW.SYS_TENANT_ID is null, 'no_tenant', NEW.SYS_TENANT_ID)^
create trigger REPORT_GROUP_SYS_TENANT_ID_NN_AND_DELETE_TS_NN_UPDATE_TRIGGER before update on REPORT_GROUP
for each row
begin
if not(NEW.SYS_TENANT_ID <=> OLD.SYS_TENANT_ID) then
set NEW.SYS_TENANT_ID_NN = if (NEW.SYS_TENANT_ID is null, 'no_tenant', NEW.SYS_TENANT_ID);
end if;
if not(NEW.DELETE_TS <=> OLD.DELETE_TS) then
set NEW.DELETE_TS_NN = if (NEW.DELETE_TS is null, '1000-01-01 00:00:00.000', NEW.DELETE_TS);
end if;
end^
/**********************************************************************************************/
create table REPORT_REPORT
(
ID varchar(32),
CREATE_TS datetime(3),
CREATED_BY varchar(50),
VERSION integer not null default 1,
UPDATE_TS datetime(3),
UPDATED_BY varchar(50),
DELETE_TS datetime(3),
DELETED_BY varchar(50),
DELETE_TS_NN datetime(3) not null default '1000-01-01 00:00:00.000',
--
NAME varchar(190) not null,
CODE varchar(255),
DESCRIPTION varchar(500),
LOCALE_NAMES text,
GROUP_ID varchar(32) not null,
REPORT_TYPE integer,
DEFAULT_TEMPLATE_ID varchar(32),
XML text,
ROLES_IDX varchar(1000),
SCREENS_IDX varchar(1000),
INPUT_ENTITY_TYPES_IDX varchar(1000),
REST_ACCESS boolean default false,
IS_SYSTEM boolean default false,
SYS_TENANT_ID varchar(255),
SYS_TENANT_ID_NN varchar(255),
--
primary key (ID),
constraint FK_REPORT_REPORT_TO_REPORT_GROUP foreign key (GROUP_ID)
references REPORT_GROUP (ID)
)^
create unique index IDX_REPORT_REPORT_UNIQ_NAME on REPORT_REPORT (NAME, SYS_TENANT_ID_NN, DELETE_TS_NN)^
create trigger REPORT_REPORT_SYS_TENANT_ID_NN_INSERT_TRIGGER before insert on REPORT_REPORT
for each row set NEW.SYS_TENANT_ID_NN = if (NEW.SYS_TENANT_ID is null, 'no_tenant', NEW.SYS_TENANT_ID)^
create trigger REPORT_REPORT_SYS_TENANT_ID_NN_AND_DELETE_TS_NN_UPDATE_TRIGGER before update on REPORT_REPORT
for each row
begin
if not(NEW.SYS_TENANT_ID <=> OLD.SYS_TENANT_ID) then
set NEW.SYS_TENANT_ID_NN = NEW.SYS_TENANT_ID;
end if;
if not(NEW.DELETE_TS <=> OLD.DELETE_TS) then
set NEW.DELETE_TS_NN = if (NEW.DELETE_TS is null, '1000-01-01 00:00:00.000', NEW.DELETE_TS);
end if;
end^
/**********************************************************************************************/
create table REPORT_TEMPLATE
(
ID varchar(32),
CREATE_TS datetime(3),
CREATED_BY varchar(50),
VERSION integer not null default 1,
UPDATE_TS datetime(3),
UPDATED_BY varchar(50),
DELETE_TS datetime(3),
DELETED_BY varchar(50),
DELETE_TS_NN datetime(3) not null default '1000-01-01 00:00:00.000',
--
REPORT_ID varchar(32) not null,
CODE varchar(50),
OUTPUT_TYPE integer default 0 not null,
IS_DEFAULT boolean default false,
IS_GROOVY boolean default false,
IS_CUSTOM boolean default false,
IS_ALTERABLE_OUTPUT boolean default false,
CUSTOM_DEFINED_BY integer default 100,
CUSTOM_CLASS text,
OUTPUT_NAME_PATTERN varchar(255),
NAME varchar(500),
CONTENT mediumblob,
--
primary key (ID),
constraint FK_REPORT_TEMPLATE_TO_REPORT foreign key (REPORT_ID)
references REPORT_REPORT (ID) on delete cascade
)^
create trigger REPORT_TEMPLATE_DELETE_TS_NN_TRIGGER before update on REPORT_TEMPLATE
for each row
if not(NEW.DELETE_TS <=> OLD.DELETE_TS) then
set NEW.DELETE_TS_NN = if (NEW.DELETE_TS is null, '1000-01-01 00:00:00.000', NEW.DELETE_TS);
end if^
/**********************************************************************************************/
create table REPORT_EXECUTION (
ID varchar(32) not null,
CREATE_TS datetime(3),
CREATED_BY varchar(50),
--
REPORT_ID varchar(32),
REPORT_NAME varchar(255) not null,
REPORT_CODE varchar(255),
USER_ID varchar(32) not null,
START_TIME datetime(3) not null,
FINISH_TIME datetime(3),
IS_SUCCESS boolean default false,
CANCELLED boolean default false,
PARAMS text,
ERROR_MESSAGE text,
SERVER_ID varchar(50),
OUTPUT_DOCUMENT_ID varchar(32),
--
primary key (ID),
constraint FK_REPORT_EXECUTION_TO_REPORT foreign key (REPORT_ID) references REPORT_REPORT(ID) on delete set null,
constraint FK_REPORT_EXECUTION_TO_USER foreign key (USER_ID) references SEC_USER(ID),
constraint FK_REPORT_EXECUTION_TO_DOCUMENT foreign key (OUTPUT_DOCUMENT_ID) references SYS_FILE(ID)
)^
create index IDX_REPORT_EXECUTION_REPORT_ID on REPORT_EXECUTION (REPORT_ID)^
create index IDX_REPORT_EXECUTION_START_TIME on REPORT_EXECUTION (START_TIME)^
/**********************************************************************************************/
alter table REPORT_REPORT add constraint FK_REPORT_REPORT_TO_DEF_TEMPLATE foreign key (DEFAULT_TEMPLATE_ID)
references REPORT_TEMPLATE (ID)^
insert into REPORT_GROUP (ID, CREATE_TS, CREATED_BY, VERSION, TITLE, CODE, LOCALE_NAMES)
values ('4e0835300b9c11e19b416bdaa41bff94', current_timestamp, 'admin', 0, 'General', 'ReportGroup.default',
concat('en=General','\n','ru=Общие'))^
|
-- phpMyAdmin SQL Dump
-- version 4.7.6
-- https://www.phpmyadmin.net/
--
-- Host: localhost
-- Generation Time: Jan 21, 2018 at 10:26 PM
-- Server version: 10.1.29-MariaDB
-- PHP Version: 7.2.0
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `projetjanvier2018`
--
-- --------------------------------------------------------
--
-- Table structure for table `article`
--
CREATE TABLE `article` (
`id_article` varchar(4) NOT NULL,
`nom_article` varchar(20) NOT NULL,
`description` varchar(20) DEFAULT NULL,
`type_article` varchar(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `article`
--
INSERT INTO `article` (`id_article`, `nom_article`, `description`, `type_article`) VALUES
('0001', 'ACERpredator', 'PCgamer', 'informatic'),
('0002', 'WinRAR', 'Licence', 'logiciel'),
('0003', 'diplomatico', '12ans', 'rhum'),
('0004', 'broche', 'kebab', 'restauration');
-- --------------------------------------------------------
--
-- Table structure for table `client`
--
CREATE TABLE `client` (
`id_client` int(255) NOT NULL,
`nom` varchar(20) NOT NULL,
`prenom` varchar(20) NOT NULL,
`localisation` varchar(50) NOT NULL,
`motdepasse` varchar(4) NOT NULL,
`telephone` varchar(10) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `client`
--
INSERT INTO `client` (`id_client`, `nom`, `prenom`, `localisation`, `motdepasse`, `telephone`) VALUES
(1, 'admin', 'admin', 'admin', '1111', '0000000000'),
(2, 'COSTA', 'Pierre', 'Lille', 'azer', '0666494510');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `article`
--
ALTER TABLE `article`
ADD PRIMARY KEY (`id_article`);
--
-- Indexes for table `client`
--
ALTER TABLE `client`
ADD PRIMARY KEY (`id_client`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `client`
--
ALTER TABLE `client`
MODIFY `id_client` int(255) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
/*drop DB objects*/
drop function members_func(varchar,members);
drop function login_func(varchar,login);
drop function expenses_func(varchar,varchar,expenses_in_t[],varchar[]);
drop function member_groups_func(varchar,member_groups[]);
drop function groups_func(character varying,groups);
drop function expenses_func(expenses_func_parameter);
drop function notes_func(varchar,varchar);
drop function notes_func(varchar,notes[],varchar[],varchar[]);
drop function tasks_func(varchar,varchar,int);
drop function tasks_func(varchar,tasks[],varchar[]);
drop function expenses_func(varchar,varchar,expenses_in_t[],varchar[]);
/*drop type interval_type;*/
drop type expenses_in_t;
drop type expenses_func_parameter;
drop table if exists schedules;
drop table if exists messages;
drop table if exists tasks;
drop table if exists notes;
drop table if exists expenses;
drop table if exists member_groups;
drop table if exists groups;
drop table if exists members;
drop table if exists login;
drop sequence if exists member_id_seq;
drop sequence if exists member_groups_id_seq;
drop sequence if exists group_id_seq;
drop sequence if exists transaction_id_seq;
drop sequence if exists note_id_seq;
drop sequence if exists task_id_seq;
drop sequence if exists message_id_seq;
drop sequence if exists schedule_id_seq;
/*User defined type*/
create type expenses_in_t as (
expense_id varchar(6),
itemname varchar(30),
date_time varchar,
costs int);
create type expenses_func_parameter as(
member_id varchar,
group_id varchar,
time_interval varchar,
start_time varchar,
end_time varchar
);
/*Table creation*/
create table login(
username varchar(15) not null,
password varchar(20) not null,
primary key (username)
);
create table Members(
member_ID varchar(6),
username varchar(15) not null,
member_name varchar(30) not null,
Email varchar(30),
Phone numeric(10,0),
primary key (member_id),
foreign key (username) references login(username));
create table groups(
group_ID varchar(6), /*Group ID will be null to represent member independent of any group*/
group_name varchar(30) not null,
primary key(group_ID));
create table member_groups(
member_group_ID varchar(8),
group_ID varchar(6),
member_ID varchar(30),
member_value bit varying, /*Test how to set or manipulate value */
primary key (member_group_ID),
foreign key (member_ID) references members(member_ID),
foreign key (group_id) references groups(group_id));
create table expenses(
transaction_ID varchar(8),
group_id varchar(6),
item varchar(30) not null,
cost integer,
expenditure_date timestamp,
expenses_shared_with bit varying,
primary key (transaction_ID),
foreign key (group_id) references groups(group_id)
/*implement check for expenses_shared_with*/);
create table tasks(
task_ID varchar(6),
group_id varchar(6),
task varchar(30) not null,
status integer,
assigned_to bit varying,
primary key(task_ID),
foreign key (group_id) references groups(group_id));
create table notes(
note_ID varchar(6),
group_id varchar(6),
text varchar(3000) not null,
share_with bit varying,
pin_to bit varying,
primary key(note_ID),
foreign key (group_id) references groups(group_id)
/*implement check for share_with and pin*/);
/*create table member_activity(
member_activity_id varchar(8),
activity_id varchar(6),
member_group_ID varchar(8))
*/
create table messages(
message_ID varchar(6),
reference_ID varchar(8),
to_ID bit varying,
from_ID bit varying,
message varchar(800) not null,
time timestamp,
privacy boolean,
tags varchar(30),
primary key(message_ID),
/* this should refer to the member_group value */
foreign key (reference_ID) references member_groups(member_group_ID),
foreign key (reference_ID) references groups(group_ID),
foreign key (reference_ID) references tasks(task_ID),
foreign key (reference_ID) references expenses(transaction_ID),
foreign key (reference_ID) references notes(note_id)
/*foreign key (to_ID) references member_groups(member_value),
foreign key (from_ID) references member_groups(member_value)*/);
create table schedules(
schedule_id varchar(6),
schedule_activity varchar(6),
start_date date,
schedule_interval interval_type,
iterations int);
/*Sequence creation*/
create sequence member_id_seq increment by 1 start with 1 no cycle;
create sequence member_groups_id_seq increment by 1 start with 1 no cycle;
create sequence group_id_seq increment by 1 start with 1 no cycle;
create sequence transaction_id_seq increment by 1 start with 1 no cycle;
create sequence task_id_seq increment by 1 start with 1 no cycle;
create sequence note_id_seq increment by 1 start with 1 no cycle;
create sequence message_id_seq increment by 1 start with 1 no cycle;
create sequence schedule_id_seq increment by 1 start with 1 no cycle; |
-- phpMyAdmin SQL Dump
-- version 4.0.10deb1ubuntu0.1
-- http://www.phpmyadmin.net
--
-- Máquina: localhost
-- Data de Criação: 25-Maio-2019 às 00:13
-- Versão do servidor: 5.5.64-MariaDB-1ubuntu0.14.04.1
-- versão do PHP: 5.5.9-1ubuntu4.29
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Base de Dados: `gu1700928`
--
-- --------------------------------------------------------
--
-- Estrutura da tabela `servico_fisio`
--
CREATE TABLE IF NOT EXISTS `servico_fisio` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`titulo` varchar(1000) NOT NULL,
`texto` varchar(1000) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;
--
-- Extraindo dados da tabela `servico_fisio`
--
INSERT INTO `servico_fisio` (`id`, `titulo`, `texto`) VALUES
(1, 'Pilates', 'Os exercícios de pilates ajudam no fortalecimento dos músculos, na diminuição de dor lombar, melhoram a respiração e circulação sanguínea (evitando inchaços e retenção de líquidos, proporcionam maior disposição, preparam as mamães para o momento do parto e acabam acalmando o bebê. As sessões devem ser realizadas 2 vezes por semana com duração de 30 a 60 minutos. O fato de as sessões serem realizadas em conjunto, permite que as gestantes interajam e troquem informações sobre suas experiências e medos, ganhando maior confiança.\nÉ importante atentar-se a fatores de riscos e respeitar o limite de cada gestante, visto que nenhuma gestação é exatamente igual, exigem tratamentos específicos.'),
(2, 'Massagem', 'As massagens podem ser realizadas tanto no meses antecedentes ao parto quanto nos posteriores ao parto. Elas estimulam a circulação sanguínea, promovem relaxamento, diminuição de dores locais e drenagem linfática (recomendado apenas no pós parto). Deve-se tomar cuidado nos locais de aplicação das massagens, evitando o adiantamento do parto e cuidando para não prejudicar o bebê.'),
(3, 'Acupuntura', 'A acupuntura deve ser realizada com muito cuidado para não afetar o bebê e não promover parto precoce. Ela traz benefícios como alívio de tensão muscular, diminuição de ansiedade, melhora da circulação sanguínea, reduz os enjoos e ameaças de aborto. No pós parto também reduz a tensão e estresse, além de estimular a produção de leite materno. \r\nExistem relatos de que fazer acupuntura durante a gestação faz com que nasçam bebês mais calmos e com menos cólicas.\r\nAssim como nas demais técnicas, a acupuntura também exige atenção à forma de aplicação para não afetar a gestação.'),
(4, 'Orientações posturais', 'A gestação é um momento em que as orientações posturais são de suma importância, já que as mulheres acabam tendo o seu centro de massa alterado o que gera, muitas vezes, inúmeras dores, alteração na marcha e incômodos ao realizar atividades diárias. Nossa clínica conta com um ambiente próprio para orientações e exercícios que promovam maior conforto e menores complicações durante os meses de gestação. Vale lembrar que por ser realizada em grupos, essa atividade promove interação e troca de informações entre as futuras mamães, amenizando as preocupações e medos.'),
(5, 'Estética', 'Serviço direcionado à clientes pós parto que procuram recuperar aspectos físicos que foram alterados durante a gestação, mais uma fez a drenagem linfática é válida, assim como tratamentos para amenizar estrias, flacidez, celulites, tratamentos de pele (afetada após tantas mudanças hormonais), entre outros procedimentos.');
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
CREATE TABLE Boards (
Title varchar(31),
Description varchar(127),
Id serial
);
CREATE TABLE Subboards (
ParentId integer,
ChildId integer
);
CREATE TABLE Threads (
Title varchar(127),
BoardId integer,
PostId integer,
Id serial
);
CREATE TABLE Posts (
ThreadId integer,
Content text,
timestamp timestamp default current_timestamp,
Id serial
);
CREATE TABLE Users (
Username varchar(127),
Passhash text, --md5 hash
AvatarId integer
);
|
-- phpMyAdmin SQL Dump
-- version 5.1.0
-- https://www.phpmyadmin.net/
--
-- Anamakine: 127.0.0.1
-- Üretim Zamanı: 17 Eki 2021, 17:49:42
-- Sunucu sürümü: 10.4.18-MariaDB
-- PHP Sürümü: 8.0.5
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Veritabanı: `kuruogluticaret`
--
-- --------------------------------------------------------
--
-- Tablo için tablo yapısı `iletisim`
--
CREATE TABLE `iletisim` (
`id` int(11) NOT NULL,
`adsoyad` varchar(30) NOT NULL,
`telefon` varchar(11) NOT NULL,
`email` varchar(30) NOT NULL,
`konu` varchar(35) NOT NULL,
`mesaj` varchar(250) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Tablo döküm verisi `iletisim`
--
INSERT INTO `iletisim` (`id`, `adsoyad`, `telefon`, `email`, `konu`, `mesaj`) VALUES
(57, 'Mertcan Kuruoğlu', '5356094333', 'mertcan95kuruoglu@gmail.com', 'Sipariş', 'adasdasdasd');
--
-- Dökümü yapılmış tablolar için indeksler
--
--
-- Tablo için indeksler `iletisim`
--
ALTER TABLE `iletisim`
ADD PRIMARY KEY (`id`);
--
-- Dökümü yapılmış tablolar için AUTO_INCREMENT değeri
--
--
-- Tablo için AUTO_INCREMENT değeri `iletisim`
--
ALTER TABLE `iletisim`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=59;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
use study;
DROP TABLE IF EXISTS `cq`;
CREATE TABLE `cq` (
`Id` int(11) NOT NULL AUTO_INCREMENT,
`hero_name` varchar(255) NOT NULL DEFAULT '' COMMENT '名字',
`hero_icon` varchar(255) NOT NULL DEFAULT '' COMMENT '头像',
`hero_sex` varchar(255) NOT NULL DEFAULT 'unknown' COMMENT '性别',
PRIMARY KEY (`Id`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
insert into cq (hero_name,hero_icon) values ('V-暴走型','V-暴走型_icon.png');
insert into cq (hero_name,hero_icon) values ('阿尔卑斯少女','阿尔卑斯少女_icon.png');
insert into cq (hero_name,hero_icon) values ('艾尔菲亚特·华伦泰','艾尔菲亚特·华伦泰_icon.png');
insert into cq (hero_name,hero_icon) values ('爱如潮涌的牛郎','爱如潮涌的牛郎_icon.png');
insert into cq (hero_name,hero_icon) values ('安德烈','安德烈_icon.png');
insert into cq (hero_name,hero_icon) values ('暗黑修女梅丽莎','暗黑修女梅丽莎_icon.png');
insert into cq (hero_name,hero_icon) values ('扒手','扒手_icon.png');
insert into cq (hero_name,hero_icon) values ('八神庵','八神庵_icon.png');
insert into cq (hero_name,hero_icon) values ('巴伦西亚骑士','巴伦西亚骑士_icon.png');
insert into cq (hero_name,hero_icon) values ('白胡子德雷克','白胡子德雷克_icon.png');
insert into cq (hero_name,hero_icon) values ('白花瓦莉','白花瓦莉_icon.png');
insert into cq (hero_name,hero_icon) values ('百发百中小光','百发百中小光_icon.png');
insert into cq (hero_name,hero_icon) values ('百万富翁桃太郎','百万富翁桃太郎_icon.png');
insert into cq (hero_name,hero_icon) values ('半精灵','半精灵_icon.png');
insert into cq (hero_name,hero_icon) values ('报丧女妖','报丧女妖_icon.png');
insert into cq (hero_name,hero_icon) values ('暴风忍者团','暴风忍者团_icon.png');
insert into cq (hero_name,hero_icon) values ('暴风雪弓手团','暴风雪弓手团_icon.png');
insert into cq (hero_name,hero_icon) values ('暴走僵尸希恩','暴走僵尸希恩_icon.png');
insert into cq (hero_name,hero_icon) values ('豹女郎','豹女郎_icon.png');
insert into cq (hero_name,hero_icon) values ('北方猎人','北方猎人_icon.png');
insert into cq (hero_name,hero_icon) values ('贝尔·格里尔斯','贝尔·格里尔斯_icon.png');
insert into cq (hero_name,hero_icon) values ('比利·凯恩','比利·凯恩_icon.png');
insert into cq (hero_name,hero_icon) values ('必胜的罗什福尔','必胜的罗什福尔_icon.png');
insert into cq (hero_name,hero_icon) values ('冰川矿工','冰川矿工_icon.png');
insert into cq (hero_name,hero_icon) values ('冰锤沃尔夫冈','冰锤沃尔夫冈_icon.png');
insert into cq (hero_name,hero_icon) values ('冰雕工匠','冰雕工匠_icon.png');
insert into cq (hero_name,hero_icon) values ('冰封王座萨斯夸奇','冰封王座萨斯夸奇_icon.png');
insert into cq (hero_name,hero_icon) values ('冰霜法师','冰霜法师_icon.png');
insert into cq (hero_name,hero_icon) values ('冰霜猎人雷芬','冰霜猎人雷芬_icon.png');
insert into cq (hero_name,hero_icon) values ('捕盗大将卞剑秀','捕盗大将卞剑秀_icon.png');
insert into cq (hero_name,hero_icon) values ('不败将军秦琼','不败将军秦琼_icon.png');
insert into cq (hero_name,hero_icon) values ('不知火舞','不知火舞_icon.png');
insert into cq (hero_name,hero_icon) values ('布蕾克·贝拉多娜','布蕾克·贝拉多娜_icon.png');
insert into cq (hero_name,hero_icon) values ('采药专家','采药专家_icon.png');
insert into cq (hero_name,hero_icon) values ('藏宝猎人','藏宝猎人_icon.png');
insert into cq (hero_name,hero_icon) values ('草薙京','草薙京_icon.png');
insert into cq (hero_name,hero_icon) values ('长老','长老_icon.png');
insert into cq (hero_name,hero_icon) values ('超杀女明蒂','超杀女明蒂_icon.png');
insert into cq (hero_name,hero_icon) values ('超自然同好会','超自然同好会_icon.png');
insert into cq (hero_name,hero_icon) values ('城镇混混','城镇混混_icon.png');
insert into cq (hero_name,hero_icon) values ('城镇青年','城镇青年_icon.png');
insert into cq (hero_name,hero_icon) values ('城镇庭院师','城镇庭院师_icon.png');
insert into cq (hero_name,hero_icon) values ('赤色弹丸孙市','赤色弹丸孙市_icon.png');
insert into cq (hero_name,hero_icon) values ('创造者宾森恩','创造者宾森恩_icon.png');
insert into cq (hero_name,hero_icon) values ('大莫离支文德','大莫离支文德_icon.png');
insert into cq (hero_name,hero_icon) values ('代号:圣诞节','代号:圣诞节_icon.png');
insert into cq (hero_name,hero_icon) values ('代号:麋鹿','代号:麋鹿_icon.png');
insert into cq (hero_name,hero_icon) values ('电子人斯佩妮','电子人斯佩妮_icon.png');
insert into cq (hero_name,hero_icon) values ('东部联军-陈','东部联军-陈_icon.png');
insert into cq (hero_name,hero_icon) values ('东部联军-汉','东部联军-汉_icon.png');
insert into cq (hero_name,hero_icon) values ('东部联军-刘','东部联军-刘_icon.png');
insert into cq (hero_name,hero_icon) values ('东部王国管理员','东部王国管理员_icon.png');
insert into cq (hero_name,hero_icon) values ('东方王国士兵','东方王国士兵_icon.png');
insert into cq (hero_name,hero_icon) values ('东瀛武士','东瀛武士_icon.png');
insert into cq (hero_name,hero_icon) values ('动物同好会','动物同好会_icon.png');
insert into cq (hero_name,hero_icon) values ('顿悟的海獭','顿悟的海獭_icon.png');
insert into cq (hero_name,hero_icon) values ('恶灵乌鸦','恶灵乌鸦_icon.png');
insert into cq (hero_name,hero_icon) values ('恶魔同好会','恶魔同好会_icon.png');
insert into cq (hero_name,hero_icon) values ('二天一流香织','二天一流香织_icon.png');
insert into cq (hero_name,hero_icon) values ('飞翼骑士','飞翼骑士_icon.png');
insert into cq (hero_name,hero_icon) values ('粉碎者斯黛拉','粉碎者斯黛拉_icon.png');
insert into cq (hero_name,hero_icon) values ('丰饶女神德米特尔','丰饶女神德米特尔_icon.png');
insert into cq (hero_name,hero_icon) values ('风华绝代织女','风华绝代织女_icon.png');
insert into cq (hero_name,hero_icon) values ('风之魔女乌尔弗兰姆','风之魔女乌尔弗兰姆_icon.png');
insert into cq (hero_name,hero_icon) values ('疯狂科学家斯坦因','疯狂科学家斯坦因_icon.png');
insert into cq (hero_name,hero_icon) values ('钢铁骑士圣女贞德','钢铁骑士圣女贞德_icon.png');
insert into cq (hero_name,hero_icon) values ('高级女仆','高级女仆_icon.png');
insert into cq (hero_name,hero_icon) values ('格兰西亚的弓手','格兰西亚的弓手_icon.png');
insert into cq (hero_name,hero_icon) values ('格兰西亚管理员','格兰西亚管理员_icon.png');
insert into cq (hero_name,hero_icon) values ('格林西亚法师','格林西亚法师_icon.png');
insert into cq (hero_name,hero_icon) values ('弓道社员','弓道社员_icon.png');
insert into cq (hero_name,hero_icon) values ('孤单寂寞的普格斯','孤单寂寞的普格斯_icon.png');
insert into cq (hero_name,hero_icon) values ('孤独的深海','孤独的深海_icon.png');
insert into cq (hero_name,hero_icon) values ('古惑仔','古惑仔_icon.png');
insert into cq (hero_name,hero_icon) values ('管家','管家_icon.png');
insert into cq (hero_name,hero_icon) values ('光明剑士里昂','光明剑士里昂_icon.png');
insert into cq (hero_name,hero_icon) values ('光之南丁格尔','光之南丁格尔_icon.png');
insert into cq (hero_name,hero_icon) values ('光之圣女团','光之圣女团_icon.png');
insert into cq (hero_name,hero_icon) values ('鬼王钟馗','鬼王钟馗_icon.png');
insert into cq (hero_name,hero_icon) values ('海军大将','海军大将_icon.png');
insert into cq (hero_name,hero_icon) values ('海军上将斯嘉丽','海军上将斯嘉丽_icon.png');
insert into cq (hero_name,hero_icon) values ('海贼','海贼_icon.png');
insert into cq (hero_name,hero_icon) values ('寒冰射手','寒冰射手_icon.png');
insert into cq (hero_name,hero_icon) values ('寒霜恶灵妮芬','寒霜恶灵妮芬_icon.png');
insert into cq (hero_name,hero_icon) values ('黑暗骑士贝恩','黑暗骑士贝恩_icon.png');
insert into cq (hero_name,hero_icon) values ('黑暗驱逐者威廉','黑暗驱逐者威廉_icon.png');
insert into cq (hero_name,hero_icon) values ('黑曼巴','黑曼巴_icon.png');
insert into cq (hero_name,hero_icon) values ('黑袍魔女桃乐丝','黑袍魔女桃乐丝_icon.png');
insert into cq (hero_name,hero_icon) values ('黑骑士莱昂内尔','黑骑士莱昂内尔_icon.png');
insert into cq (hero_name,hero_icon) values ('黑手党','黑手党_icon.png');
insert into cq (hero_name,hero_icon) values ('黑桃王后爱丽丝','黑桃王后爱丽丝_icon.png');
insert into cq (hero_name,hero_icon) values ('红莲之弓矢德姆娜','红莲之弓矢德姆娜_icon.png');
insert into cq (hero_name,hero_icon) values ('红色丝绸','红色丝绸_icon.png');
insert into cq (hero_name,hero_icon) values ('狐狸射手','狐狸射手_icon.png');
insert into cq (hero_name,hero_icon) values ('护士学生','护士学生_icon.png');
insert into cq (hero_name,hero_icon) values ('荒狂电光夏尔美','荒狂电光夏尔美_icon.png');
insert into cq (hero_name,hero_icon) values ('黄道军阿库里埃斯','黄道军阿库里埃斯_icon.png');
insert into cq (hero_name,hero_icon) values ('黄道军阿莉耶丝','黄道军阿莉耶丝_icon.png');
insert into cq (hero_name,hero_icon) values ('黄道军比尔高','黄道军比尔高_icon.png');
insert into cq (hero_name,hero_icon) values ('黄道军卡布里','黄道军卡布里_icon.png');
insert into cq (hero_name,hero_icon) values ('黄道军卡伊','黄道军卡伊_icon.png');
insert into cq (hero_name,hero_icon) values ('黄道军里奥','黄道军里奥_icon.png');
insert into cq (hero_name,hero_icon) values ('黄道军里夫','黄道军里夫_icon.png');
insert into cq (hero_name,hero_icon) values ('黄道军蛇夫','黄道军蛇夫_icon.png');
insert into cq (hero_name,hero_icon) values ('黄道军双胞胎','黄道军双胞胎_icon.png');
insert into cq (hero_name,hero_icon) values ('黄道军斯塔琉斯','黄道军斯塔琉斯_icon.png');
insert into cq (hero_name,hero_icon) values ('黄道军天蝎','黄道军天蝎_icon.png');
insert into cq (hero_name,hero_icon) values ('黄道军韬','黄道军韬_icon.png');
insert into cq (hero_name,hero_icon) values ('黄金射手团','黄金射手团_icon.png');
insert into cq (hero_name,hero_icon) values ('皇帝亚历山大','皇帝亚历山大_icon.png');
insert into cq (hero_name,hero_icon) values ('皇家保洁','皇家保洁_icon.png');
insert into cq (hero_name,hero_icon) values ('皇家厨师','皇家厨师_icon.png');
insert into cq (hero_name,hero_icon) values ('皇家稽查队','皇家稽查队_icon.png');
insert into cq (hero_name,hero_icon) values ('皇家魔法学生','皇家魔法学生_icon.png');
insert into cq (hero_name,hero_icon) values ('皇家亲卫队','皇家亲卫队_icon.png');
insert into cq (hero_name,hero_icon) values ('皇家田径部','皇家田径部_icon.png');
insert into cq (hero_name,hero_icon) values ('皇家文学部','皇家文学部_icon.png');
insert into cq (hero_name,hero_icon) values ('火焰之迎春','火焰之迎春_icon.png');
insert into cq (hero_name,hero_icon) values ('火之魔女莎莎','火之魔女莎莎_icon.png');
insert into cq (hero_name,hero_icon) values ('机甲弓手','机甲弓手_icon.png');
insert into cq (hero_name,hero_icon) values ('机械工程学家','机械工程学家_icon.png');
insert into cq (hero_name,hero_icon) values ('机械少女-0','机械少女-0_icon.png');
insert into cq (hero_name,hero_icon) values ('机械少女','机械少女_icon.png');
insert into cq (hero_name,hero_icon) values ('稽查队员','稽查队员_icon.png');
insert into cq (hero_name,hero_icon) values ('极地猎人','极地猎人_icon.png');
insert into cq (hero_name,hero_icon) values ('疾风半藏','疾风半藏_icon.png');
insert into cq (hero_name,hero_icon) values ('记者','记者_icon.png');
insert into cq (hero_name,hero_icon) values ('见习骑士','见习骑士_icon.png');
insert into cq (hero_name,hero_icon) values ('见习铁匠','见习铁匠_icon.png');
insert into cq (hero_name,hero_icon) values ('见习武斗家','见习武斗家_icon.png');
insert into cq (hero_name,hero_icon) values ('剑道社员','剑道社员_icon.png');
insert into cq (hero_name,hero_icon) values ('将军须佐能乎','将军须佐能乎_icon.png');
insert into cq (hero_name,hero_icon) values ('教团仆人','教团仆人_icon.png');
insert into cq (hero_name,hero_icon) values ('劫匪','劫匪_icon.png');
insert into cq (hero_name,hero_icon) values ('节制的芬里尔','节制的芬里尔_icon.png');
insert into cq (hero_name,hero_icon) values ('金','金_icon.png');
insert into cq (hero_name,hero_icon) values ('精灵德鲁伊','精灵德鲁伊_icon.png');
insert into cq (hero_name,hero_icon) values ('警卫员','警卫员_icon.png');
insert into cq (hero_name,hero_icon) values ('九品芝麻官','九品芝麻官_icon.png');
insert into cq (hero_name,hero_icon) values ('九尾狐阿狸','九尾狐阿狸_icon.png');
insert into cq (hero_name,hero_icon) values ('酒吧老板','酒吧老板_icon.png');
insert into cq (hero_name,hero_icon) values ('救世的圣母玛利亚','救世的圣母玛利亚_icon.png');
insert into cq (hero_name,hero_icon) values ('觉醒的雅甘','觉醒的雅甘_icon.png');
insert into cq (hero_name,hero_icon) values ('绝地武士','绝地武士_icon.png');
insert into cq (hero_name,hero_icon) values ('绝对魔王薇薇安','绝对魔王薇薇安_icon.png');
insert into cq (hero_name,hero_icon) values ('凯·奇斯库','凯·奇斯库_icon.png');
insert into cq (hero_name,hero_icon) values ('考古学家','考古学家_icon.png');
insert into cq (hero_name,hero_icon) values ('可爱巧克莉','可爱巧克莉_icon.png');
insert into cq (hero_name,hero_icon) values ('狂欢城镇管理员','狂欢城镇管理员_icon.png');
insert into cq (hero_name,hero_icon) values ('拉姆蕾萨尔·华伦泰','拉姆蕾萨尔·华伦泰_icon.png');
insert into cq (hero_name,hero_icon) values ('蓝骑士·比乌斯','蓝骑士·比乌斯_icon.png');
insert into cq (hero_name,hero_icon) values ('蓝骑士·大卫','蓝骑士·大卫_icon.png');
insert into cq (hero_name,hero_icon) values ('蓝骑士·杰西','蓝骑士·杰西_icon.png');
insert into cq (hero_name,hero_icon) values ('蓝骑士·拉维亚','蓝骑士·拉维亚_icon.png');
insert into cq (hero_name,hero_icon) values ('蓝骑士阿雷西亚','蓝骑士阿雷西亚_icon.png');
insert into cq (hero_name,hero_icon) values ('蓝骑士艾米莉亚','蓝骑士艾米莉亚_icon.png');
insert into cq (hero_name,hero_icon) values ('蓝骑士拉伊勒','蓝骑士拉伊勒_icon.png');
insert into cq (hero_name,hero_icon) values ('蓝骑士里尼亚','蓝骑士里尼亚_icon.png');
insert into cq (hero_name,hero_icon) values ('蓝骑士尤格林','蓝骑士尤格林_icon.png');
insert into cq (hero_name,hero_icon) values ('狼族卫士','狼族卫士_icon.png');
insert into cq (hero_name,hero_icon) values ('浪漫的麦格尼斯','浪漫的麦格尼斯_icon.png');
insert into cq (hero_name,hero_icon) values ('雷神托尔','雷神托尔_icon.png');
insert into cq (hero_name,hero_icon) values ('蕾拉','蕾拉_icon.png');
insert into cq (hero_name,hero_icon) values ('莉安娜·哈迪兰','莉安娜·哈迪兰_icon.png');
insert into cq (hero_name,hero_icon) values ('料理武术家雷玲','料理武术家雷玲_icon.png');
insert into cq (hero_name,hero_icon) values ('猎人莱瑟','猎人莱瑟_icon.png');
insert into cq (hero_name,hero_icon) values ('猎鹰','猎鹰_icon.png');
insert into cq (hero_name,hero_icon) values ('猎鹰队员','猎鹰队员_icon.png');
insert into cq (hero_name,hero_icon) values ('猎鹰精英','猎鹰精英_icon.png');
insert into cq (hero_name,hero_icon) values ('邻家大爷','邻家大爷_icon.png');
insert into cq (hero_name,hero_icon) values ('龙骑士齐格弗里德','龙骑士齐格弗里德_icon.png');
insert into cq (hero_name,hero_icon) values ('露比·罗丝','露比·罗丝_icon.png');
insert into cq (hero_name,hero_icon) values ('绿色妖精','绿色妖精_icon.png');
insert into cq (hero_name,hero_icon) values ('罗曼共和国管理员','罗曼共和国管理员_icon.png');
insert into cq (hero_name,hero_icon) values ('罗曼祭司','罗曼祭司_icon.png');
insert into cq (hero_name,hero_icon) values ('罗曼女射手','罗曼女射手_icon.png');
insert into cq (hero_name,hero_icon) values ('罗曼士兵','罗曼士兵_icon.png');
insert into cq (hero_name,hero_icon) values ('麻宫雅典娜','麻宫雅典娜_icon.png');
insert into cq (hero_name,hero_icon) values ('猫咪大师喵','猫咪大师喵_icon.png');
insert into cq (hero_name,hero_icon) values ('毛熊同好会','毛熊同好会_icon.png');
insert into cq (hero_name,hero_icon) values ('梅尔','梅尔_icon.png');
insert into cq (hero_name,hero_icon) values ('梅伊','梅伊_icon.png');
insert into cq (hero_name,hero_icon) values ('美少年','美少年_icon.png');
insert into cq (hero_name,hero_icon) values ('美食家阿索斯','美食家阿索斯_icon.png');
insert into cq (hero_name,hero_icon) values ('美食猎人彩依','美食猎人彩依_icon.png');
insert into cq (hero_name,hero_icon) values ('美式足球社员','美式足球社员_icon.png');
insert into cq (hero_name,hero_icon) values ('蒙泰终极型','蒙泰终极型_icon.png');
insert into cq (hero_name,hero_icon) values ('米莉亚·蕾姬','米莉亚·蕾姬_icon.png');
insert into cq (hero_name,hero_icon) values ('密使罗宾汉','密使罗宾汉_icon.png');
insert into cq (hero_name,hero_icon) values ('民族英雄郑成功','民族英雄郑成功_icon.png');
insert into cq (hero_name,hero_icon) values ('名侦探夏洛克','名侦探夏洛克_icon.png');
insert into cq (hero_name,hero_icon) values ('魔导工程师','魔导工程师_icon.png');
insert into cq (hero_name,hero_icon) values ('魔法傀儡师贝萝特','魔法傀儡师贝萝特_icon.png');
insert into cq (hero_name,hero_icon) values ('魔法少女明日香','魔法少女明日香_icon.png');
insert into cq (hero_name,hero_icon) values ('魔法学徒','魔法学徒_icon.png');
insert into cq (hero_name,hero_icon) values ('魔女宅急便','魔女宅急便_icon.png');
insert into cq (hero_name,hero_icon) values ('末世杜尔拉汗','末世杜尔拉汗_icon.png');
insert into cq (hero_name,hero_icon) values ('牧师','牧师_icon.png');
insert into cq (hero_name,hero_icon) values ('南方海军','南方海军_icon.png');
insert into cq (hero_name,hero_icon) values ('南方警备队员','南方警备队员_icon.png');
insert into cq (hero_name,hero_icon) values ('南方亲卫队','南方亲卫队_icon.png');
insert into cq (hero_name,hero_icon) values ('南西部联盟管理员','南西部联盟管理员_icon.png');
insert into cq (hero_name,hero_icon) values ('妮欧','妮欧_icon.png');
insert into cq (hero_name,hero_icon) values ('涅斯帝国管理员','涅斯帝国管理员_icon.png');
insert into cq (hero_name,hero_icon) values ('涅斯革命军','涅斯革命军_icon.png');
insert into cq (hero_name,hero_icon) values ('涅斯革命军的弓手','涅斯革命军的弓手_icon.png');
insert into cq (hero_name,hero_icon) values ('涅斯工程师','涅斯工程师_icon.png');
insert into cq (hero_name,hero_icon) values ('涅斯军长官尤莉娅','涅斯军长官尤莉娅_icon.png');
insert into cq (hero_name,hero_icon) values ('涅斯军乐队','涅斯军乐队_icon.png');
insert into cq (hero_name,hero_icon) values ('涅斯军团女巫','涅斯军团女巫_icon.png');
insert into cq (hero_name,hero_icon) values ('涅斯魔导兵团','涅斯魔导兵团_icon.png');
insert into cq (hero_name,hero_icon) values ('涅斯突击队','涅斯突击队_icon.png');
insert into cq (hero_name,hero_icon) values ('牛仔梅西','牛仔梅西_icon.png');
insert into cq (hero_name,hero_icon) values ('扭蛋鲁格斯','扭蛋鲁格斯_icon.png');
insert into cq (hero_name,hero_icon) values ('扭蛋战队B','扭蛋战队B_icon.png');
insert into cq (hero_name,hero_icon) values ('扭蛋战队G','扭蛋战队G_icon.png');
insert into cq (hero_name,hero_icon) values ('扭蛋战队K','扭蛋战队K_icon.png');
insert into cq (hero_name,hero_icon) values ('扭蛋战队P','扭蛋战队P_icon.png');
insert into cq (hero_name,hero_icon) values ('扭蛋战队R','扭蛋战队R_icon.png');
insert into cq (hero_name,hero_icon) values ('扭蛋战队Y','扭蛋战队Y_icon.png');
insert into cq (hero_name,hero_icon) values ('女警','女警_icon.png');
insert into cq (hero_name,hero_icon) values ('女忍者','女忍者_icon.png');
insert into cq (hero_name,hero_icon) values ('女神教祭司','女神教祭司_icon.png');
insert into cq (hero_name,hero_icon) values ('女神教平信徒','女神教平信徒_icon.png');
insert into cq (hero_name,hero_icon) values ('女神教守护骑士','女神教守护骑士_icon.png');
insert into cq (hero_name,hero_icon) values ('女神教图书馆管理员','女神教图书馆管理员_icon.png');
insert into cq (hero_name,hero_icon) values ('女神教修炼祭司','女神教修炼祭司_icon.png');
insert into cq (hero_name,hero_icon) values ('女神教修炼骑士','女神教修炼骑士_icon.png');
insert into cq (hero_name,hero_icon) values ('女神教异端审判者','女神教异端审判者_icon.png');
insert into cq (hero_name,hero_icon) values ('女童子军','女童子军_icon.png');
insert into cq (hero_name,hero_icon) values ('诺拉·瓦尔基里','诺拉·瓦尔基里_icon.png');
insert into cq (hero_name,hero_icon) values ('诺斯加尔德管理员','诺斯加尔德管理员_icon.png');
insert into cq (hero_name,hero_icon) values ('欧米茄·卢卡尔','欧米茄·卢卡尔_icon.png');
insert into cq (hero_name,hero_icon) values ('皮拉·尼可丝','皮拉·尼可丝_icon.png');
insert into cq (hero_name,hero_icon) values ('平凡的魔法师','平凡的魔法师_icon.png');
insert into cq (hero_name,hero_icon) values ('普格斯','普格斯_icon.png');
insert into cq (hero_name,hero_icon) values ('奇普·萨那弗','奇普·萨那弗_icon.png');
insert into cq (hero_name,hero_icon) values ('骑士候补','骑士候补_icon.png');
insert into cq (hero_name,hero_icon) values ('千骑兵志愿生','千骑兵志愿生_icon.png');
insert into cq (hero_name,hero_icon) values ('枪手','枪手_icon.png');
insert into cq (hero_name,hero_icon) values ('枪术教官','枪术教官_icon.png');
insert into cq (hero_name,hero_icon) values ('乔尼','乔尼_icon.png');
insert into cq (hero_name,hero_icon) values ('巧克莉','巧克莉_icon.png');
insert into cq (hero_name,hero_icon) values ('亲卫队','亲卫队_icon.png');
insert into cq (hero_name,hero_icon) values ('青苹果','青苹果_icon.png');
insert into cq (hero_name,hero_icon) values ('倾国倾城春香','倾国倾城春香_icon.png');
insert into cq (hero_name,hero_icon) values ('人气服务生','人气服务生_icon.png');
insert into cq (hero_name,hero_icon) values ('荣誉者凯伦','荣誉者凯伦_icon.png');
insert into cq (hero_name,hero_icon) values ('萨满','萨满_icon.png');
insert into cq (hero_name,hero_icon) values ('塞拉亲卫队','塞拉亲卫队_icon.png');
insert into cq (hero_name,hero_icon) values ('森林魔女娅莉塔','森林魔女娅莉塔_icon.png');
insert into cq (hero_name,hero_icon) values ('森林骑士','森林骑士_icon.png');
insert into cq (hero_name,hero_icon) values ('森林卫士','森林卫士_icon.png');
insert into cq (hero_name,hero_icon) values ('森罗万象海獭','森罗万象海獭_icon.png');
insert into cq (hero_name,hero_icon) values ('沙漠枪手','沙漠枪手_icon.png');
insert into cq (hero_name,hero_icon) values ('沙漠战士','沙漠战士_icon.png');
insert into cq (hero_name,hero_icon) values ('少年农夫','少年农夫_icon.png');
insert into cq (hero_name,hero_icon) values ('少女','少女_icon.png');
insert into cq (hero_name,hero_icon) values ('少数民族联合管理员','少数民族联合管理员_icon.png');
insert into cq (hero_name,hero_icon) values ('哨兵R','哨兵R_icon.png');
insert into cq (hero_name,hero_icon) values ('神乐千鹤','神乐千鹤_icon.png');
insert into cq (hero_name,hero_icon) values ('神女卑弥呼','神女卑弥呼_icon.png');
insert into cq (hero_name,hero_icon) values ('审判者文森特','审判者文森特_icon.png');
insert into cq (hero_name,hero_icon) values ('圣诞老人','圣诞老人_icon.png');
insert into cq (hero_name,hero_icon) values ('圣都旅行者','圣都旅行者_icon.png');
insert into cq (hero_name,hero_icon) values ('圣都巡礼者','圣都巡礼者_icon.png');
insert into cq (hero_name,hero_icon) values ('圣都之守护者诺埃尔','圣都之守护者诺埃尔_icon.png');
insert into cq (hero_name,hero_icon) values ('圣都住民','圣都住民_icon.png');
insert into cq (hero_name,hero_icon) values ('圣魔该隐','圣魔该隐_icon.png');
insert into cq (hero_name,hero_icon) values ('圣女团志愿生','圣女团志愿生_icon.png');
insert into cq (hero_name,hero_icon) values ('使者赛莲','使者赛莲_icon.png');
insert into cq (hero_name,hero_icon) values ('噬魂射手No.9','噬魂射手No.9_icon.png');
insert into cq (hero_name,hero_icon) values ('视死如归达达尼昂','视死如归达达尼昂_icon.png');
insert into cq (hero_name,hero_icon) values ('收割者塞特','收割者塞特_icon.png');
insert into cq (hero_name,hero_icon) values ('首席舞蹈家李','首席舞蹈家李_icon.png');
insert into cq (hero_name,hero_icon) values ('书呆子','书呆子_icon.png');
insert into cq (hero_name,hero_icon) values ('树星国士兵','树星国士兵_icon.png');
insert into cq (hero_name,hero_icon) values ('双面人鲁伊希尔拉','双面人鲁伊希尔拉_icon.png');
insert into cq (hero_name,hero_icon) values ('司令斯派洛','司令斯派洛_icon.png');
insert into cq (hero_name,hero_icon) values ('丝绒射手','丝绒射手_icon.png');
insert into cq (hero_name,hero_icon) values ('死灵法师内克伦','死灵法师内克伦_icon.png');
insert into cq (hero_name,hero_icon) values ('苏醒的贝斯派','苏醒的贝斯派_icon.png');
insert into cq (hero_name,hero_icon) values ('索尔·巴德凯','索尔·巴德凯_icon.png');
insert into cq (hero_name,hero_icon) values ('塔普娘','塔普娘_icon.png');
insert into cq (hero_name,hero_icon) values ('太阳之战士','太阳之战士_icon.png');
insert into cq (hero_name,hero_icon) values ('探究者罗蕾莱','探究者罗蕾莱_icon.png');
insert into cq (hero_name,hero_icon) values ('探险家','探险家_icon.png');
insert into cq (hero_name,hero_icon) values ('特别的研究员','特别的研究员_icon.png');
insert into cq (hero_name,hero_icon) values ('特瑞·博加德','特瑞·博加德_icon.png');
insert into cq (hero_name,hero_icon) values ('铁女修尔拉','铁女修尔拉_icon.png');
insert into cq (hero_name,hero_icon) values ('铁人28号','铁人28号_icon.png');
insert into cq (hero_name,hero_icon) values ('童话作家','童话作家_icon.png');
insert into cq (hero_name,hero_icon) values ('屠魔猎手溪谷莉娜','屠魔猎手溪谷莉娜_icon.png');
insert into cq (hero_name,hero_icon) values ('屠杀者哈尔菲亚','屠杀者哈尔菲亚_icon.png');
insert into cq (hero_name,hero_icon) values ('万能的乌帕','万能的乌帕_icon.png');
insert into cq (hero_name,hero_icon) values ('万圣节巧克莉','万圣节巧克莉_icon.png');
insert into cq (hero_name,hero_icon) values ('魏丝·雪倪','魏丝·雪倪_icon.png');
insert into cq (hero_name,hero_icon) values ('无限的贝阿朵莉切','无限的贝阿朵莉切_icon.png');
insert into cq (hero_name,hero_icon) values ('武装女仆迪雅','武装女仆迪雅_icon.png');
insert into cq (hero_name,hero_icon) values ('五虎大将军韩胜','五虎大将军韩胜_icon.png');
insert into cq (hero_name,hero_icon) values ('舞者','舞者_icon.png');
insert into cq (hero_name,hero_icon) values ('吸血鬼','吸血鬼_icon.png');
insert into cq (hero_name,hero_icon) values ('稀世怪盗路尼昂','稀世怪盗路尼昂_icon.png');
insert into cq (hero_name,hero_icon) values ('先知墨菲斯','先知墨菲斯_icon.png');
insert into cq (hero_name,hero_icon) values ('乡村姑娘','乡村姑娘_icon.png');
insert into cq (hero_name,hero_icon) values ('小丑','小丑_icon.png');
insert into cq (hero_name,hero_icon) values ('小红帽','小红帽_icon.png');
insert into cq (hero_name,hero_icon) values ('小太妹','小太妹_icon.png');
insert into cq (hero_name,hero_icon) values ('辛·奇斯库','辛·奇斯库_icon.png');
insert into cq (hero_name,hero_icon) values ('星光之娅莉娅','星光之娅莉娅_icon.png');
insert into cq (hero_name,hero_icon) values ('熊孩子','熊孩子_icon.png');
insert into cq (hero_name,hero_icon) values ('熊叔','熊叔_icon.png');
insert into cq (hero_name,hero_icon) values ('修道院长','修道院长_icon.png');
insert into cq (hero_name,hero_icon) values ('修道院守护者','修道院守护者_icon.png');
insert into cq (hero_name,hero_icon) values ('修女','修女_icon.png');
insert into cq (hero_name,hero_icon) values ('修女教官','修女教官_icon.png');
insert into cq (hero_name,hero_icon) values ('虚无的福斯特','虚无的福斯特_icon.png');
insert into cq (hero_name,hero_icon) values ('雪人','雪人_icon.png');
insert into cq (hero_name,hero_icon) values ('驯龙高手·坤','驯龙高手·坤_icon.png');
insert into cq (hero_name,hero_icon) values ('亚马逊','亚马逊_icon.png');
insert into cq (hero_name,hero_icon) values ('阎罗使者桂香','阎罗使者桂香_icon.png');
insert into cq (hero_name,hero_icon) values ('炎之宿命克里斯','炎之宿命克里斯_icon.png');
insert into cq (hero_name,hero_icon) values ('阳赫','阳赫_icon.png');
insert into cq (hero_name,hero_icon) values ('阳小龙','阳小龙_icon.png');
insert into cq (hero_name,hero_icon) values ('夜魔女麻美','夜魔女麻美_icon.png');
insert into cq (hero_name,hero_icon) values ('夜之女王瑞秋','夜之女王瑞秋_icon.png');
insert into cq (hero_name,hero_icon) values ('医务社员','医务社员_icon.png');
insert into cq (hero_name,hero_icon) values ('伊诺','伊诺_icon.png');
insert into cq (hero_name,hero_icon) values ('意志坚定的赫克托尔','意志坚定的赫克托尔_icon.png');
insert into cq (hero_name,hero_icon) values ('异端审判官乌列','异端审判官乌列_icon.png');
insert into cq (hero_name,hero_icon) values ('异能者伊莎贝尔','异能者伊莎贝尔_icon.png');
insert into cq (hero_name,hero_icon) values ('音乐同好会','音乐同好会_icon.png');
insert into cq (hero_name,hero_icon) values ('阴阳师晴明','阴阳师晴明_icon.png');
insert into cq (hero_name,hero_icon) values ('吟游诗人','吟游诗人_icon.png');
insert into cq (hero_name,hero_icon) values ('引导者奥西里斯','引导者奥西里斯_icon.png');
insert into cq (hero_name,hero_icon) values ('引领者伊西丝','引领者伊西丝_icon.png');
insert into cq (hero_name,hero_icon) values ('鹰之女儿拉喜玛','鹰之女儿拉喜玛_icon.png');
insert into cq (hero_name,hero_icon) values ('勇犬剑士','勇犬剑士_icon.png');
insert into cq (hero_name,hero_icon) values ('幽灵公主贝欧琳','幽灵公主贝欧琳_icon.png');
insert into cq (hero_name,hero_icon) values ('诱惑之奥菲欧','诱惑之奥菲欧_icon.png');
insert into cq (hero_name,hero_icon) values ('御医','御医_icon.png');
insert into cq (hero_name,hero_icon) values ('约定之维多利亚','约定之维多利亚_icon.png');
insert into cq (hero_name,hero_icon) values ('约束者克里姆希尔特','约束者克里姆希尔特_icon.png');
insert into cq (hero_name,hero_icon) values ('月光女神莉莉丝','月光女神莉莉丝_icon.png');
insert into cq (hero_name,hero_icon) values ('月光追击者阿塔兰特','月光追击者阿塔兰特_icon.png');
insert into cq (hero_name,hero_icon) values ('月姬辉夜姬','月姬辉夜姬_icon.png');
insert into cq (hero_name,hero_icon) values ('月亮花伊吹','月亮花伊吹_icon.png');
insert into cq (hero_name,hero_icon) values ('月野红','月野红_icon.png');
insert into cq (hero_name,hero_icon) values ('月圆奇波郎','月圆奇波郎_icon.png');
insert into cq (hero_name,hero_icon) values ('战场上的圣女雅典娜','战场上的圣女雅典娜_icon.png');
insert into cq (hero_name,hero_icon) values ('战斗机器人_特-6','战斗机器人_特-6_icon.png');
insert into cq (hero_name,hero_icon) values ('战斗祭司','战斗祭司_icon.png');
insert into cq (hero_name,hero_icon) values ('战神阿基里斯','战神阿基里斯_icon.png');
insert into cq (hero_name,hero_icon) values ('治安官','治安官_icon.png');
insert into cq (hero_name,hero_icon) values ('治愈术士','治愈术士_icon.png');
insert into cq (hero_name,hero_icon) values ('中央帝国士兵','中央帝国士兵_icon.png');
insert into cq (hero_name,hero_icon) values ('钟表店老板','钟表店老板_icon.png');
insert into cq (hero_name,hero_icon) values ('主持人','主持人_icon.png');
insert into cq (hero_name,hero_icon) values ('专职打劫犯','专职打劫犯_icon.png');
insert into cq (hero_name,hero_icon) values ('状元李梦龙','状元李梦龙_icon.png');
insert into cq (hero_name,hero_icon) values ('椎拳崇','椎拳崇_icon.png');
insert into cq (hero_name,hero_icon) values ('追求幸福的达拉','追求幸福的达拉_icon.png');
insert into cq (hero_name,hero_icon) values ('自然的纳兹伦','自然的纳兹伦_icon.png');
insert into cq (hero_name,hero_icon) values ('自由部队管理员','自由部队管理员_icon.png');
insert into cq (hero_name,hero_icon) values ('族长乌兹门特','族长乌兹门特_icon.png');
insert into cq (hero_name,hero_icon) values ('最初的帕拉丁罗兰','最初的帕拉丁罗兰_icon.png');
insert into cq (hero_name,hero_icon) values ('最强佣兵斯内克','最强佣兵斯内克_icon.png');
insert into cq (hero_name,hero_icon) values ('冥帝博格斯','冥帝博格斯_icon.png');
insert into cq (hero_name,hero_icon) values ('喵奇奇','喵奇奇_icon.png');
insert into cq (hero_name,hero_icon) values ('喵星人','喵星人_icon.png');
insert into cq (hero_name,hero_icon) values ('狩魔猎人亚伯','狩魔猎人亚伯_icon.png');
insert into cq (hero_name,hero_icon) values ('婕克·欧','婕克·欧_icon.png');
insert into cq (hero_name,hero_icon) values ('樵夫','樵夫_icon.png');
insert into cq (hero_name,hero_icon) values ('窈窕淑女','窈窕淑女_icon.png'); |
-- Deletes the database hbtn_0c_0 from the MySQL server,
-- do nothing if the hbtn_0c_0 database doesn't exist.
DROP DATABASE IF EXISTS `hbtn_0c_0`;
|
DROP TABLE transactions;
DROP TABLE orders;
DROP TABLE item_tags;
DROP TABLE items;
DROP TABLE tags;
DROP TABLE manufacturers;
CREATE TABLE manufacturers (
id SERIAL8 PRIMARY KEY,
name VARCHAR(255),
website VARCHAR(255)
);
CREATE TABLE tags (
id SERIAL8 PRIMARY KEY,
title VARCHAR(144)
);
CREATE TABLE items (
id SERIAL8 PRIMARY KEY,
name VARCHAR(255),
description VARCHAR(255),
cost INT8,
price INT8,
stock_level INT4,
stock_low INT4,
stock_medium INT4,
manufacturer_id INT8 REFERENCES manufacturers(id)
);
CREATE TABLE item_tags(
id SERIAL8 PRIMARY KEY,
tag_id INT8 REFERENCES tags(id),
item_id INT8 REFERENCES items(id)
);
CREATE TABLE orders (
id SERIAL8 PRIMARY KEY,
order_date DATE,
is_sold BOOLEAN,
is_processed BOOLEAN
);
CREATE TABLE transactions (
id SERIAL8 PRIMARY KEY,
item_id INT8 REFERENCES items(id),
order_id INT8 REFERENCES orders(id),
amount INT4
);
|
-- phpMyAdmin SQL Dump
-- version 4.9.0.1
-- https://www.phpmyadmin.net/
--
-- Host: localhost
-- Generation Time: Jul 11, 2019 at 10:18 AM
-- Server version: 10.3.15-MariaDB
-- PHP Version: 7.3.6
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `company`
--
-- --------------------------------------------------------
--
-- Table structure for table `ms_company`
--
CREATE TABLE `ms_company` (
`company_id` int(11) NOT NULL,
`company_name` varchar(50) NOT NULL,
`company_address` text NOT NULL,
`company_phone` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `ms_company`
--
INSERT INTO `ms_company` (`company_id`, `company_name`, `company_address`, `company_phone`) VALUES
(12, 'PT. Mutiara', 'Bandung', 98765654),
(13, 'PT. BRI', 'Jakarta Selatan', 987654343),
(16, 'PT. Cafe', 'Bekasi Barat', 99999999),
(18, 'PT. GSI', 'Jakarta Utara', 56565656);
-- --------------------------------------------------------
--
-- Table structure for table `ms_employee`
--
CREATE TABLE `ms_employee` (
`employee_id` int(11) NOT NULL,
`company_id` int(11) NOT NULL,
`employee_gender` int(11) NOT NULL,
`employee_birthday` date NOT NULL,
`employee_picture` varchar(100) NOT NULL,
`employee_phone` varchar(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Indexes for dumped tables
--
--
-- Indexes for table `ms_company`
--
ALTER TABLE `ms_company`
ADD PRIMARY KEY (`company_id`);
--
-- Indexes for table `ms_employee`
--
ALTER TABLE `ms_employee`
ADD PRIMARY KEY (`employee_id`),
ADD KEY `index` (`company_id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `ms_company`
--
ALTER TABLE `ms_company`
MODIFY `company_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=19;
--
-- AUTO_INCREMENT for table `ms_employee`
--
ALTER TABLE `ms_employee`
MODIFY `employee_id` int(11) NOT NULL AUTO_INCREMENT;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `ms_employee`
--
ALTER TABLE `ms_employee`
ADD CONSTRAINT `fk_employee_company` FOREIGN KEY (`company_id`) REFERENCES `ms_company` (`company_id`);
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
CREATE PROCEDURE `getPostByCategory`(IN `channel` INT)
BEGIN
SELECT * FROM `post` WHERE `channel_id`=`channel`;
END
CREATE PROCEDURE `createPostNow`(IN `employee_id` VARCHAR(50), IN `channel_id` INT, IN `post_title` VARCHAR(50), IN `post_content` VARCHAR(500), IN `post_image` MEDIUMBLOB, IN `report_count` INT)
BEGIN
INSERT INTO `post` (`employee_id`, `channel_id`, `date_posted`, `post_content`, `report_count`)
VALUES (`employee_id`, `channel_id`, NOW(), `post_content`, `report_count`);
SELECT LAST_INSERT_ID();
END
CREATE PROCEDURE `deletePost` (IN `post_id` INT)
BEGIN
DELETE FROM `post` WHERE post.post_id=`post_id` ;
END
CREATE PROCEDURE `deletePostAssertUser`(IN `post_id` INT, IN `employee_id` VARCHAR(50))
BEGIN
DELETE FROM `post` WHERE post.post_id=`post_id` AND post.employee_id=`employee_id` ;
END
CREATE PROCEDURE `getPostByCategoryWithEmployeeInfo`(IN `channel` INT)
BEGIN
SELECT post.post_id, post.employee_id, post.channel_id, post.date_posted, post.post_content, post.report_count, employee.first_name, employee.last_name, employee.profile_photo FROM `post`
INNER JOIN `employee` ON employee.employee_id=post.employee_id
WHERE post.channel_id = `channel`
ORDER BY post.date_posted DESC LIMIT 30;
END
CREATE PROCEDURE `getReportedPosts`()
BEGIN
SELECT post.post_id, post.employee_id, post.channel_id, post.date_posted, post.post_content, post.report_count, employee.first_name, employee.last_name, employee.profile_photo FROM `post`
INNER JOIN `employee` ON employee.employee_id=post.employee_id
WHERE post.report_count > 0
ORDER BY post.date_posted DESC LIMIT 30;
END
CREATE PROCEDURE `reportPost`(IN `post_id` INT)
BEGIN
UPDATE `post` SET post.report_count=post.report_count+1 WHERE post.post_id=`post_id` ;
END
CREATE PROCEDURE `clearReports`(IN `post_id` INT)
BEGIN
UPDATE `post` SET post.report_count=0 WHERE post.post_id=`post_id`;
END |
# 函数
-- 和存储过程的区别:返回值,函数只能有一个返回,而且必须有返回
-- 存储过程适合批量插入,更新
-- 函数适合处理数据后,得到一个结果,适合查询
/* 基本语法
CREATE FUNCTION 名(参数列表) RETURNS 返回类型
BEGIN
函数体
(必须有return 语句)
(函数体只有一句话,可以省略BEGIN END)
END
-- 调用函数
SELECT fun();
*/
delimiter $
CREATE FUNCTION fun1() RETURNS INT
BEGIN
DECLARE count INT DEFAULT 0;
SELECT COUNT(*) INTO count
FROM myemployees.employees;
RETURN count;
END $
SELECT fun1();
--
CREATE FUNCTION getPriceFromId(empId INT) RETURNS DOUBLE
BEGIN
DECLARE price DOUBLE DEFAULT 0.0;
SELECT employees.price INTO price FROM employees WHERE employee_id = empId;
RETURN price;
END
-- 查看函数
SHOW CREATE FUNCTION getPriceFromId
DROP FUNCTION getPriceFromId
-- 循环结构
/*
三种循环:
WHILE :
标签:WHILE 条件 DO
循环体
END WHILE 标签;
LOOP:
标签: LOOP
循环体;
IF 退出条件 THEN
LEAVE 标签;
END IF;
END LOOP 标签;
REPEAT:
标签:REPEAT
循环体
UNTIL 结束条件 END REPEAT 标签;
循环控制语句:
ITERATE(继续,结束本次继续下次)
LEAVE (break,跳出所在循环)
*/
delimiter $
CREATE PROCEDURE batch(num INT)
BEGIN
DECLARE i INT DEFAULT 1;
WHILE i <= num DO
INSERT INTO `user` (age, username, `password`) VALUES (i, CONCAT('user',i), CONCAT('1101@',i));
SET i = i + 1;
END WHILE;
END $
CALL batch(10000)
|
select modelcod, version
from model
where version LIKE 'A3%'; |
--VARUN SHOURIE
/*
Query 1
What are the cities, companies, and contacts for Northwind's customers that live in a city starting with an M or an S, sorted by company name?
*/
SELECT City, CompanyName, ContactName, ContactTitle
FROM Customers
WHERE City LIKE "M%" OR City LIKE "S%"
ORDER BY CompanyName;
/*
Query 2
To check for missing data, what are the names of Northwind's employees, sorted by last name, that do not have a region listed in the database?
*/
SELECT LastName, FirstName
FROM Employees
WHERE Region IS NULL
ORDER BY LastName;
/*
Query 3
To further check for missing data, add city to the last query and check for the employees that do not work in Seattle and do not have a region listed. No need to sort the output.
*/
SELECT LastName, FirstName, City
FROM Employees
WHERE Region IS NULL AND City != "Seattle";
/*
Query 4
What are the employees responsible for a sale (last name only), the ID of the order, the shipping name, shipping country, and shipping fee for orders placed to ship to customers in the UK and Ireland?
Sort these results by employee last name. Also, for readability purposes format the field names as “Employee Last Name”, “Order ID”, “Freight Company”, “Destination Country”, and “Shipping Cost”, respectively
*/
SELECT LastName AS 'Employee Last Name', OrderID AS 'Order ID', ShipName AS 'Freight Company', ShipCountry AS 'Destination Country', Freight AS 'Shipping Cost'
FROM Employees
JOIN Orders
ON Employees.EmployeeID = Orders.EmployeeID
WHERE ShipCountry IN ("UK", "Ireland")
ORDER BY LastName;
/*
Query 5
How many customers does Northwind have in each country in which they do business? Rename the fields in the output for readability.
*/
SELECT COUNT("CustomerID") AS "Number of Customers", Country AS "Country of Customers"
FROM Customers
GROUP BY Country;
|
USE tienda_libros;
DROP FUNCTION IF EXISTS act3g;
CREATE TEMPORARY TABLE IF NOT EXISTS tmpserie(subcat VARCHAR(45), cant INT);
DELIMITER //
CREATE FUNCTION act3g(nombre VARCHAR(45), cant INT) RETURNS VARCHAR(45)
BEGIN
DECLARE istart INT;
SET istart = 1;
WHILE istart < cant DO
INSERT INTO `tmpserie` (subcat, cant)
SELECT
subcategoria.subcategoria,
COUNT(subcategoria.subcategoria)
FROM
libro,
usuario,
libro_has_subcategoria,
subcategoria
WHERE
libro.idusuario = usuario.idusuario
AND libro_has_subcategoria.idlibro = libro.idlibro
AND libro_has_subcategoria.idsubcategoria = subcategoria.idsubcategoria
AND subcategoria.idsubcategoria = istart;
SET istart = istart + 1;
END WHILE;
SET @catMasVis = ( SELECT subcat FROM tmpserie ORDER BY cant LIMIT 1);
RETURN @catMasVis;
END //
SELECT act3g("Carlos", 21) AS "Subcategoría más visitada"; |
!!! funkcje matematyczne !!!
abs wartość bezwzględna abs(-17.4) = 17.4
cbrt pierwiastek sześcienny cbrt(27.0) = 3
ceil najmniejszy integer nie mniejszy niż argumentu ceil(-42.8) = -42
ceiling to samo co ceil ceiling(-95.3) = -95
degrees konwersja radianów na stopnie degrees(0.5) = 28.6478897565412
div dzielenie div(9,4) = 2
exp exp exp(1.0) = 2.71828182845905
floor największy integer nie większy niż argument floor(-42.8) = -43
ln logarytm naturalny ln(2.0) = 0.693147180559945
log dla 1 argumentu logarytm o podstawie 10 log(100.0) = 2
log dla 2 argumentów logarytm o podanej podstawie log(2.0, 64.0) = 6.0
mod reszta z dzielenia mod(9,4) = 1
pi wartość pi pi() = 3.14159265358979
power potęgowanie power(9, 3) = 729
radians konwersja stopni do radianów radians(45.0) = 0.785398163397448
random losowa wartość z zakresu <0,1>
round dla 1 argumentu zaokrągla do najbliższej liczby całkowitej round(42.4) = 42
round dla 2 argumentów zaokrągla do określonej liczby miejsc po przecinku round(42.4382, 2) = 42.44
setseed ustawia ziarno (od -1.0 do 1.0) dla następnego wywołania funkcji random setseed(0.54823)
sign znak argumentu: -1, 0, lub +1 sign(-8.4) = -1
sqrt pierwiastek kwadratowy sqrt(2.0) = 1,442135623731
trunc dla 1 argumentu usuwa część dziesiętną trunc(42.8) = 42
trunc dla 2 argumentów usuwa wszystkie dalsze cyfry niż podana dokładność trunc(42.4382, 2) = 42.43
funkcje trygonometryczne: acos, asin, atan, atan2, cos, cot, sin, tan
wszystkie funkcje poza atan2 przyjmują jeden argument: x
funkcja atan2 przyjmuje 2 argumenty: y i x
!!! funkcja generate_series !!! // funkcja generate_series może zwrócić więcej niż jeden wiersz
generate_series(start, stop) - generuje zbiór wieszy zawierających wartość typu int lub bigint o zakresie <start, stop> i kroku wartości 1
generate_series(start, stop, step) - generuje zbiór wieszy zawierających wartość typu int lub bigint o zakresie <start, stop> i kroku step
generate_series(start, stop, step) - generuje zbiór wieszy zawierających wartość typu timestamp lub timestamp with time zone (zależy od typu argumentu step) o zakresie <start, stop> i kroku step
!!! funkcje ciągów znaków !!!
bit_length(string) - liczba bitów w stringu :: bit_length('jose') = 32
char_length(string) - liczba znaków w stringu :: char_lenght('jose') = 4
lower(string) - zamiana liter na małe :: lower('Tom') = tom
octet_length(string) - liczba bajtów w stringu :: octet_length('jose') = 4
overlay(string PLACING string from int [FOR int]) - zamienia część stringu :: overlay('Txxxas' placing 'hom' from 2 for 4) = Thomas
md5(string) - zwraca hexadecymalną wartość wyniku hashowania MD5 podanego stringa :: md5('abc') = 900150983cd24fb0 d6963f7d28e17f72
position(substring IN string) - zwraca pozycję (numer znaku) w stringu :: position('om' in 'Thonas') = 3
repeat(string text, number int) - zwraca string powtórzony n razy :: repeat('Pg', 4) = PgPgPgPg
replace(string text, from text, to text) - zmienia wszystkie wystąpienia tekstu from na text to w podanym stringu :: replace('abcdefabcdef', 'cd', 'XX') = abXXefabXXef
reverse(string) - zwraca string o odwróconej kolejnosci znaków :: reverse('abcde') == edcba
split_part(string text, delimiter text, field int) - dzieli string na podstawie podanego znaku i zwraca n-ty (field, liczony od wartości 1) podstring :: split_part('ab.cd', '.', 2) == cd
substring(string [FROM int] [FOR int]) - zwraca fragment stringu :: substring('Thomas' from 2 for 3) = hom
substring(string FROM pattern) - zwraca fragment stringu pasujący do wyrażenia regularnego POSIX :: substring('Thomas' from '...$') = mas
substring(string FROM pattern FOR escape) - zwraca fragment stringu pasujący do wyrażenia regularnego SQL :: substring('Thomas' from '%#"o_a#"_' for '#') = oma
trim([LEADING | TRAILING | BOTH] [characters] FROM string) - usuwa najdłuższy ciąg składający się z podanych znaków (domyślnie spacje) :: trim(both 'x' from 'xThomxx') = Tom
upper(string) - zamiana liter na małe :: lower('Tom') = TOM
!!! funkcje wspierające typ JSON !!! // dostępne od wersji 9.2
array_to_json(anyarray [, pretty_bool]) - zwraca tablicę jako JSON, znaki nowej lini są dodanane pomiędzy elementami pierwszego poziomu jeśi pretty_bool ma wartość true
row_to_json(record [, pretty_bool]) - zwraca wiersz jako JSON, znaki nowej lini są dodanane pomiędzy elementami pierwszego poziomu jeśi pretty_bool ma wartość true
|
/*
Navicat Premium Data Transfer
Source Server : LK_Connection
Source Server Type : MySQL
Source Server Version : 80018
Source Host : localhost:3306
Source Schema : cm
Target Server Type : MySQL
Target Server Version : 80018
File Encoding : 65001
Date: 23/04/2020 10:06:26
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for activity
-- ----------------------------
DROP TABLE IF EXISTS `activity`;
CREATE TABLE `activity` (
`id` int(10) NOT NULL COMMENT '自增ID',
`image` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '活动图片路径',
`title` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '活动标题',
`content` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '活动内容',
`address` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '活动地址',
`number` int(10) NOT NULL COMMENT '活动人数',
`date` datetime(0) NOT NULL COMMENT '活动日期',
`publisher` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '活动发布者',
`publishDate` datetime(0) NOT NULL COMMENT '活动发布日期',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for activity_register
-- ----------------------------
DROP TABLE IF EXISTS `activity_register`;
CREATE TABLE `activity_register` (
`id` int(10) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
`act_id` int(10) NOT NULL COMMENT '外键绑定活动ID',
`hh_id` int(11) NOT NULL COMMENT '外键绑定住户ID',
`telephone` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '联系电话',
`num` int(5) NOT NULL COMMENT '报名人数',
PRIMARY KEY (`id`) USING BTREE,
INDEX `act_rst_activity_fk`(`act_id`) USING BTREE,
INDEX `act_rst_hh_fk`(`hh_id`) USING BTREE,
CONSTRAINT `act_rst_activity_fk` FOREIGN KEY (`act_id`) REFERENCES `activity` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT `act_rst_hh_fk` FOREIGN KEY (`hh_id`) REFERENCES `household` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for admin
-- ----------------------------
DROP TABLE IF EXISTS `admin`;
CREATE TABLE `admin` (
`id` int(10) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
`username` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '账号',
`password` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '000000' COMMENT '密码(默认6个0)',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for admin_role
-- ----------------------------
DROP TABLE IF EXISTS `admin_role`;
CREATE TABLE `admin_role` (
`id` int(10) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
`adminId` int(10) NOT NULL COMMENT '外键绑定管理员ID',
`roleId` int(10) NOT NULL COMMENT '外键绑定角色ID',
PRIMARY KEY (`id`) USING BTREE,
INDEX `admin_ar_fk`(`adminId`) USING BTREE,
INDEX `role_ar_fk`(`roleId`) USING BTREE,
CONSTRAINT `admin_ar_fk` FOREIGN KEY (`adminId`) REFERENCES `admin` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT `role_ar_fk` FOREIGN KEY (`roleId`) REFERENCES `role` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for building
-- ----------------------------
DROP TABLE IF EXISTS `building`;
CREATE TABLE `building` (
`id` int(10) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
`buildName` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '楼栋名',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for charge
-- ----------------------------
DROP TABLE IF EXISTS `charge`;
CREATE TABLE `charge` (
`id` int(10) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
`name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '缴费项目名称',
`desc` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '缴费项目描述',
`standard` double(10, 0) NOT NULL COMMENT '缴费标准(金额)',
`creationDate` datetime(0) NOT NULL COMMENT '创建日期',
`note` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
PRIMARY KEY (`id`) USING BTREE,
INDEX `standard`(`standard`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for facility
-- ----------------------------
DROP TABLE IF EXISTS `facility`;
CREATE TABLE `facility` (
`id` int(10) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
`name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '设施名称',
`cateId` int(10) NOT NULL COMMENT '外键绑定分类ID',
`num` int(10) NOT NULL COMMENT '设施购入数量',
`price` double(10, 0) NOT NULL COMMENT '设施价格',
`purchaseDate` datetime(0) NOT NULL COMMENT '购买日期',
PRIMARY KEY (`id`) USING BTREE,
INDEX `fac_fac_category_fk`(`cateId`) USING BTREE,
CONSTRAINT `fac_fac_category_fk` FOREIGN KEY (`cateId`) REFERENCES `facility_category` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for facility_category
-- ----------------------------
DROP TABLE IF EXISTS `facility_category`;
CREATE TABLE `facility_category` (
`id` int(10) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
`cateName` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '设施分类名称',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for feedback
-- ----------------------------
DROP TABLE IF EXISTS `feedback`;
CREATE TABLE `feedback` (
`id` int(10) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
`householdId` int(10) NOT NULL COMMENT '外键绑定住户ID',
`content` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '反馈内容',
`date` datetime(0) NOT NULL COMMENT '反馈日期',
`status` int(1) NOT NULL COMMENT '反馈回复状态(0表示未回复,1表示已回复)',
`reply` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '回复信息',
PRIMARY KEY (`id`) USING BTREE,
INDEX `feedback_hh-fk`(`householdId`) USING BTREE,
CONSTRAINT `feedback_hh-fk` FOREIGN KEY (`householdId`) REFERENCES `household` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for fire_security
-- ----------------------------
DROP TABLE IF EXISTS `fire_security`;
CREATE TABLE `fire_security` (
`id` int(10) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
`buildId` int(10) NOT NULL COMMENT '外键绑定楼栋ID',
`createDate` datetime(0) NOT NULL COMMENT '记录创建日期',
`checkContent` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '检查内容',
`level` int(1) NULL DEFAULT NULL COMMENT '消防状态等级(0差,需要更新,1良好,2优秀)',
`checkDate` datetime(0) NULL DEFAULT NULL COMMENT '检查日期',
`updateDate` datetime(0) NULL DEFAULT NULL COMMENT '更新日期',
PRIMARY KEY (`id`) USING BTREE,
INDEX `fs_build_fk`(`buildId`) USING BTREE,
CONSTRAINT `fs_build_fk` FOREIGN KEY (`buildId`) REFERENCES `building` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for household
-- ----------------------------
DROP TABLE IF EXISTS `household`;
CREATE TABLE `household` (
`id` int(10) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
`name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '真实姓名',
`gender` varchar(1) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '性别(男 或 女)',
`age` int(5) NULL DEFAULT NULL COMMENT '年龄',
`telephone` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '联系电话',
`IDcard` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '身份证号码',
`arrivalDate` datetime(0) NULL DEFAULT NULL COMMENT '入住日期',
`isOwner` int(1) NOT NULL COMMENT '是否为业主(1表示是,0表示否)',
`buildingId` int(10) NOT NULL COMMENT '外键绑定楼栋ID',
`roomId` int(10) NOT NULL COMMENT '外键绑定房间ID',
PRIMARY KEY (`id`) USING BTREE,
INDEX `build_hh_fk`(`buildingId`) USING BTREE,
INDEX `room_ff_fk`(`roomId`) USING BTREE,
CONSTRAINT `build_hh_fk` FOREIGN KEY (`buildingId`) REFERENCES `building` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT `room_ff_fk` FOREIGN KEY (`roomId`) REFERENCES `room` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for maintenance
-- ----------------------------
DROP TABLE IF EXISTS `maintenance`;
CREATE TABLE `maintenance` (
`id` int(10) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
`facilityId` int(10) NOT NULL COMMENT '外键绑定设施iD',
`content` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '维护内容',
`status` int(1) NOT NULL COMMENT '维护状态(0表示未维护,1表示已维护)',
`cost` double(10, 0) NULL DEFAULT NULL COMMENT '维护费用',
`createDate` datetime(0) NOT NULL COMMENT '记录创建日期',
`date` datetime(0) NULL DEFAULT NULL COMMENT '维护日期',
`note` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
PRIMARY KEY (`id`) USING BTREE,
INDEX `mt_fac_fk`(`facilityId`) USING BTREE,
CONSTRAINT `mt_fac_fk` FOREIGN KEY (`facilityId`) REFERENCES `facility` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for news
-- ----------------------------
DROP TABLE IF EXISTS `news`;
CREATE TABLE `news` (
`id` int(10) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
`image` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '新闻图片路径',
`title` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '新闻标题',
`content` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '新闻内容',
`author` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '作者',
`date` datetime(0) NOT NULL COMMENT '发布日期',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for payment
-- ----------------------------
DROP TABLE IF EXISTS `payment`;
CREATE TABLE `payment` (
`id` int(10) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
`householdId` int(10) NOT NULL COMMENT '外键绑定住户ID',
`charId` int(10) NOT NULL COMMENT '外键绑定缴费项目ID',
`charStandard` double(10, 0) NOT NULL COMMENT '外键绑定缴费标准',
`payReal` double(10, 0) NULL DEFAULT NULL COMMENT '实际支付',
`payStatus` int(1) NOT NULL COMMENT '支付状态(1表示已支付,0表示未支付)',
`payDate` datetime(0) NULL DEFAULT NULL COMMENT '支付日期',
PRIMARY KEY (`id`) USING BTREE,
INDEX `pay_hh_fk`(`householdId`) USING BTREE,
INDEX `pay_charge_fk`(`charId`) USING BTREE,
INDEX `pay_chargeS_fk`(`charStandard`) USING BTREE,
CONSTRAINT `pay_chargeS_fk` FOREIGN KEY (`charStandard`) REFERENCES `charge` (`standard`) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT `pay_charge_fk` FOREIGN KEY (`charId`) REFERENCES `charge` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT `pay_hh_fk` FOREIGN KEY (`householdId`) REFERENCES `household` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for permission
-- ----------------------------
DROP TABLE IF EXISTS `permission`;
CREATE TABLE `permission` (
`id` int(10) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
`permission` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '管理权限',
`description` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '权限描述',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for repair
-- ----------------------------
DROP TABLE IF EXISTS `repair`;
CREATE TABLE `repair` (
`id` int(10) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
`householdId` int(10) NOT NULL COMMENT '外键绑定住户ID',
`name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '报修住户姓名',
`telephone` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '联系电话',
`content` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '报修内容',
`date` datetime(0) NOT NULL COMMENT '报修日期',
`status` int(1) NOT NULL COMMENT '报修状态(1表示已解决,0表示未解决)',
`reply` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '回复信息',
PRIMARY KEY (`id`) USING BTREE,
INDEX `repair_hh_fk`(`householdId`) USING BTREE,
CONSTRAINT `repair_hh_fk` FOREIGN KEY (`householdId`) REFERENCES `household` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for role
-- ----------------------------
DROP TABLE IF EXISTS `role`;
CREATE TABLE `role` (
`id` int(10) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
`role` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '角色',
`description` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '角色描述',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for role_permission
-- ----------------------------
DROP TABLE IF EXISTS `role_permission`;
CREATE TABLE `role_permission` (
`id` int(10) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
`roleId` int(10) NOT NULL COMMENT '外键绑定角色ID',
`permissionId` int(10) NOT NULL COMMENT '外键绑定权限ID',
PRIMARY KEY (`id`) USING BTREE,
INDEX `role_rp_fk`(`roleId`) USING BTREE,
INDEX `permission_rp_fk`(`permissionId`) USING BTREE,
CONSTRAINT `permission_rp_fk` FOREIGN KEY (`permissionId`) REFERENCES `permission` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT `role_rp_fk` FOREIGN KEY (`roleId`) REFERENCES `role` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for room
-- ----------------------------
DROP TABLE IF EXISTS `room`;
CREATE TABLE `room` (
`id` int(10) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
`buildingId` int(10) NOT NULL COMMENT '外键绑定楼栋ID',
`roomNum` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '房间号',
PRIMARY KEY (`id`) USING BTREE,
INDEX `room_building_fk`(`buildingId`) USING BTREE,
CONSTRAINT `room_building_fk` FOREIGN KEY (`buildingId`) REFERENCES `building` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for user
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
`id` int(10) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
`hh_id` int(10) NOT NULL COMMENT '外键关联住户id',
`account` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '住户账号',
`password` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '123456' COMMENT '住户密码(默认123456)',
`unionId` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '住户绑定微信?',
`openId` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '住户绑定微信?',
PRIMARY KEY (`id`) USING BTREE,
INDEX `user_hh_fk`(`hh_id`) USING BTREE,
CONSTRAINT `user_hh_fk` FOREIGN KEY (`hh_id`) REFERENCES `household` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
SET FOREIGN_KEY_CHECKS = 1;
|
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (15,1,1,1,1);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (15.75,1,1,3,1);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (16.5,1,1,4,1);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (15,2,1,5,2);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (15.75,2,1,6,2);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (16.5,2,1,2,2);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (15,3,1,13,5);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (15.75,3,1,14,5);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (16.5,3,1,15,5);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (12,4,2,10,4);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (12.6,4,2,11,4);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (13.2,4,2,12,4);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (12,5,2,5,2);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (12.6,5,2,6,2);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (13.2,5,2,2,2);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (12,6,2,13,5);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (12.6,6,2,14,5);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (13.2,6,2,15,5);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (40,7,3,5,2);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (42,7,3,6,2);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (44,7,3,2,2);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (40,8,3,1,1);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (42,8,3,3,1);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (44,8,3,4,1);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (40,9,3,7,3);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (42,9,3,8,3);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (44,9,3,9,3);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (65,10,4,7,3);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (68.25,10,4,8,3);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (71.5,10,4,9,3);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (65,11,4,13,5);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (68.25,11,4,14,5);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (71.5,11,4,15,5);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (65,12,4,5,2);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (68.25,12,4,6,2);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (71.5,12,4,2,2);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (19,13,5,5,2);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (19.95,13,5,6,2);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (20.9,13,5,2,2);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (19,14,5,10,4);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (19.95,14,5,11,4);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (20.9,14,5,12,4);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (19,15,5,1,1);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (19.95,15,5,3,1);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (20.9,15,5,4,1);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (20,16,6,7,3);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (21,16,6,8,3);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (22,16,6,9,3);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (20,17,6,1,1);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (21,17,6,3,1);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (22,17,6,4,1);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (20,18,6,5,2);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (21,18,6,6,2);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (22,18,6,2,2);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (11,19,7,10,4);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (11.55,19,7,11,4);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (12.1,19,7,12,4);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (11,20,7,7,3);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (11.55,20,7,8,3);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (12.1,20,7,9,3);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (11,21,7,5,2);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (11.55,21,7,6,2);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (12.1,21,7,2,2);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (13,22,8,7,3);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (13.65,22,8,8,3);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (14.3,22,8,9,3);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (13,23,8,10,4);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (13.65,23,8,11,4);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (14.3,23,8,12,4);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (13,24,8,13,5);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (13.65,24,8,14,5);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (14.3,24,8,15,5);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (10,25,9,5,2);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (10.5,25,9,6,2);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (11,25,9,2,2);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (10,26,9,13,5);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (10.5,26,9,14,5);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (11,26,9,15,5);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (10,27,9,1,1);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (10.5,27,9,3,1);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (11,27,9,4,1);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (59,28,10,7,3);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (61.95,28,10,8,3);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (64.9,28,10,9,3);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (59,29,10,10,4);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (61.95,29,10,11,4);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (64.9,29,10,12,4);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (59,30,10,5,2);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (61.95,30,10,6,2);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (64.9,30,10,2,2);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (25,31,11,1,1);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (26.25,31,11,3,1);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (27.5,31,11,4,1);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (25,32,11,5,2);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (26.25,32,11,6,2);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (27.5,32,11,2,2);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (25,33,11,7,3);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (26.25,33,11,8,3);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (27.5,33,11,9,3);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (23,34,12,10,4);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (24.15,34,12,11,4);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (25.3,34,12,12,4);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (23,35,12,5,2);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (24.15,35,12,6,2);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (25.3,35,12,2,2);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (23,36,12,13,5);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (24.15,36,12,14,5);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (25.3,36,12,15,5);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (17,37,13,7,3);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (17.85,37,13,8,3);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (18.7,37,13,9,3);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (17,38,13,5,2);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (17.85,38,13,6,2);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (18.7,38,13,2,2);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (17,39,13,13,5);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (17.85,39,13,14,5);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (18.7,39,13,15,5);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (23,40,14,1,1);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (24.15,40,14,3,1);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (25.3,40,14,4,1);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (23,41,14,13,5);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (24.15,41,14,14,5);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (25.3,41,14,15,5);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (23,42,14,5,2);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (24.15,42,14,6,2);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (25.3,42,14,2,2);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (16,43,15,7,3);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (16.8,43,15,8,3);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (17.6,43,15,9,3);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (16,44,15,10,4);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (16.8,44,15,11,4);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (17.6,44,15,12,4);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (16,45,15,13,5);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (16.8,45,15,14,5);
INSERT INTO tickets(starting_price, representation_id, show_id, section_id, auditorium_id)
VALUES (17.6,45,15,15,5); |
create table order_products
(
quantity integer not null,
order_id bigint not null,
product_id bigint not null
);
create table orders
(
id bigint generated by default as identity,
date_created date,
status varchar(255)
);
create table products
(
id bigint generated by default as identity,
name varchar(25) not null,
picture_url varchar(55),
price double precision
);
|
CREATE TABLE game (
id MEDIUMINT NOT NULL AUTO_INCREMENT,
createdtimestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id)
);
CREATE TABLE user (
id MEDIUMINT NOT NULL AUTO_INCREMENT,
createdtimestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
handle TEXT,
PRIMARY KEY (id)
);
CREATE TABLE gameuser (
id MEDIUMINT NOT NULL AUTO_INCREMENT,
gameid MEDIUMINT,
userid MEDIUMINT,
PRIMARY KEY (id)
);
CREATE TABLE history (
id MEDIUMINT NOT NULL AUTO_INCREMENT,
createdtimestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
gameid MEDIUMINT,
action TEXT,
PRIMARY KEY (id)
);
CREATE TABLE gametype (
id MEDIUMINT NOT NULL AUTO_INCREMENT,
gameid MEDIUMINT,
gametype TEXT,
PRIMARY KEY (id)
);
CREATE TABLE city (
id MEDIUMINT NOT NULL AUTO_INCREMENT,
name TEXT,
PRIMARY KEY (id)
);
1 INSERT INTO city (name) VALUES('Torino');
2 INSERT INTO city (name) VALUES('Milano');
3 INSERT INTO city (name) VALUES('Venezia');
4 INSERT INTO city (name) VALUES('Genova');
5 INSERT INTO city (name) VALUES('Mantova');
6 INSERT INTO city (name) VALUES('Ferrara');
7 INSERT INTO city (name) VALUES('Parma');
8 INSERT INTO city (name) VALUES('Modena');
9 INSERT INTO city (name) VALUES('Bologna');
10 INSERT INTO city (name) VALUES('Lucca');
11 INSERT INTO city (name) VALUES('Firenze');
12 INSERT INTO city (name) VALUES('Urbino');
13 INSERT INTO city (name) VALUES('Siena');
14 INSERT INTO city (name) VALUES('Spoleto');
15 INSERT INTO city (name) VALUES('Ancona');
16 INSERT INTO city (name) VALUES('Roma');
17 INSERT INTO city (name) VALUES('Napoli');
CREATE TABLE cityconnection (
id MEDIUMINT NOT NULL AUTO_INCREMENT,
cityid MEDIUMINT,
connection MEDIUMINT,
PRIMARY KEY (id)
);
INSERT INTO cityconnection (cityid, connection) VALUES(1, 2);
INSERT INTO cityconnection (cityid, connection) VALUES(1, 4);
INSERT INTO cityconnection (cityid, connection) VALUES(2, 1);
INSERT INTO cityconnection (cityid, connection) VALUES(2, 4);
INSERT INTO cityconnection (cityid, connection) VALUES(2, 3);
INSERT INTO cityconnection (cityid, connection) VALUES(2, 5);
INSERT INTO cityconnection (cityid, connection) VALUES(2, 7);
INSERT INTO cityconnection (cityid, connection) VALUES(2, 8);
INSERT INTO cityconnection (cityid, connection) VALUES(3, 2);
INSERT INTO cityconnection (cityid, connection) VALUES(3, 5);
INSERT INTO cityconnection (cityid, connection) VALUES(3, 6);
INSERT INTO cityconnection (cityid, connection) VALUES(4, 1);
INSERT INTO cityconnection (cityid, connection) VALUES(4, 2);
INSERT INTO cityconnection (cityid, connection) VALUES(4, 7);
INSERT INTO cityconnection (cityid, connection) VALUES(5, 2);
INSERT INTO cityconnection (cityid, connection) VALUES(5, 3);
INSERT INTO cityconnection (cityid, connection) VALUES(5, 6);
INSERT INTO cityconnection (cityid, connection) VALUES(5, 8);
INSERT INTO cityconnection (cityid, connection) VALUES(6, 3);
INSERT INTO cityconnection (cityid, connection) VALUES(6, 5);
INSERT INTO cityconnection (cityid, connection) VALUES(6, 9);
INSERT INTO cityconnection (cityid, connection) VALUES(6, 8);
INSERT INTO cityconnection (cityid, connection) VALUES(7, 2);
INSERT INTO cityconnection (cityid, connection) VALUES(7, 4);
INSERT INTO cityconnection (cityid, connection) VALUES(7, 8);
INSERT INTO cityconnection (cityid, connection) VALUES(7, 10);
INSERT INTO cityconnection (cityid, connection) VALUES(8, 2);
INSERT INTO cityconnection (cityid, connection) VALUES(8, 5);
INSERT INTO cityconnection (cityid, connection) VALUES(8, 6);
INSERT INTO cityconnection (cityid, connection) VALUES(8, 7);
INSERT INTO cityconnection (cityid, connection) VALUES(8, 10);
INSERT INTO cityconnection (cityid, connection) VALUES(8, 9);
INSERT INTO cityconnection (cityid, connection) VALUES(8, 11);
INSERT INTO cityconnection (cityid, connection) VALUES(9, 6);
INSERT INTO cityconnection (cityid, connection) VALUES(9, 8);
INSERT INTO cityconnection (cityid, connection) VALUES(9, 11);
INSERT INTO cityconnection (cityid, connection) VALUES(9, 12);
INSERT INTO cityconnection (cityid, connection) VALUES(10, 7);
INSERT INTO cityconnection (cityid, connection) VALUES(10, 8);
INSERT INTO cityconnection (cityid, connection) VALUES(10, 11);
INSERT INTO cityconnection (cityid, connection) VALUES(11, 8);
INSERT INTO cityconnection (cityid, connection) VALUES(11, 9);
INSERT INTO cityconnection (cityid, connection) VALUES(11, 10);
INSERT INTO cityconnection (cityid, connection) VALUES(11, 12);
INSERT INTO cityconnection (cityid, connection) VALUES(11, 13);
INSERT INTO cityconnection (cityid, connection) VALUES(11, 14);
INSERT INTO cityconnection (cityid, connection) VALUES(11, 16);
INSERT INTO cityconnection (cityid, connection) VALUES(12, 9);
INSERT INTO cityconnection (cityid, connection) VALUES(12, 11);
INSERT INTO cityconnection (cityid, connection) VALUES(12, 14);
INSERT INTO cityconnection (cityid, connection) VALUES(12, 15);
INSERT INTO cityconnection (cityid, connection) VALUES(13, 11);
INSERT INTO cityconnection (cityid, connection) VALUES(13, 16);
INSERT INTO cityconnection (cityid, connection) VALUES(14, 11);
INSERT INTO cityconnection (cityid, connection) VALUES(14, 12);
INSERT INTO cityconnection (cityid, connection) VALUES(14, 16);
INSERT INTO cityconnection (cityid, connection) VALUES(14, 15);
INSERT INTO cityconnection (cityid, connection) VALUES(14, 17);
INSERT INTO cityconnection (cityid, connection) VALUES(15, 12);
INSERT INTO cityconnection (cityid, connection) VALUES(15, 13);
INSERT INTO cityconnection (cityid, connection) VALUES(15, 17);
INSERT INTO cityconnection (cityid, connection) VALUES(16, 11);
INSERT INTO cityconnection (cityid, connection) VALUES(16, 13);
INSERT INTO cityconnection (cityid, connection) VALUES(16, 14);
INSERT INTO cityconnection (cityid, connection) VALUES(16, 17);
INSERT INTO cityconnection (cityid, connection) VALUES(17, 14);
INSERT INTO cityconnection (cityid, connection) VALUES(17, 15);
INSERT INTO cityconnection (cityid, connection) VALUES(17, 16);
CREATE TABLE cityinstance (
id MEDIUMINT NOT NULL AUTO_INCREMENT,
gameid MEDIUMINT,
cityid MEDIUMINT,
owner MEDIUMINT NULL,
bishop BOOLEAN,
condottiere BOOLEAN,
PRIMARY KEY (id)
);
CREATE TABLE gamestatus (
id MEDIUMINT NOT NULL AUTO_INCREMENT,
gameid MEDIUMINT,
started BOOLEAN,
PRIMARY KEY (id)
); |
create database db_pizzaria_legal;
use db_pizzaria_legal;
-- Criando tb_categoria
create table tb_categoria(
id bigint auto_increment,
nome varchar(255) not null,
localidade varchar(255) not null,
tipo varchar(255) not null,
primary key(id)
);
-- Criando tb_pizza
create table tb_pizza (
id bigint auto_increment,
nomePizza varchar(255) not null,
borda enum('SIM', 'NÃO') not null,
massa varchar(255) not null,
tamanho varchar(255) not null,
preço bigint not null,
categoria_id bigint,
primary key (id),
foreign key (categoria_id) references tb_categoria(id)
);
-- Populando tb_categoria
insert into tb_categoria(nome, localidade, tipo) values ("Torre da Pizza", "São Paulo", "doce");
insert into tb_categoria(nome, localidade, tipo) values ("Domino's", "Embu das Artes", "vegana");
insert into tb_categoria(nome, localidade, tipo) values ("Belas Artes", "Taboão da Serra", "tradicional");
insert into tb_categoria(nome, localidade, tipo) values ("Torre da Pizza 3", "Av. Paulista", "tradicional");
insert into tb_categoria(nome, localidade, tipo) values ("Jet Pizza", "São Paulo", "promoção");
-- Populando tb_pizza
insert into tb_pizza(nomePizza, borda, massa, tamanho, preço, categoria_id) values ("Toscana","SIM", "fina", "grande", 35.00,1);
insert into tb_pizza(nomePizza, borda, massa, tamanho, preço, categoria_id) values ("Marguerita","SIM", "média", "média", 40.00,2);
insert into tb_pizza(nomePizza, borda, massa, tamanho, preço, categoria_id) values ("Calabresa","SIM", "grossa", "pequena", 10.00,3);
insert into tb_pizza(nomePizza, borda, massa, tamanho, preço, categoria_id) values ("Calabresa","NÃO", "fina", "grande", 28.00,4);
insert into tb_pizza(nomePizza, borda, massa, tamanho, preço, categoria_id) values ("Moda da Casa","SIM", "fina", "média", 50.00,5);
insert into tb_pizza(nomePizza, borda, massa, tamanho, preço, categoria_id) values ("Portuguesa","NÃO", "grossa", "grande", 55.00,2);
insert into tb_pizza(nomePizza, borda, massa, tamanho, preço, categoria_id) values ("Brigadeiro","SIM", "média", "grande", 70.00,1);
insert into tb_pizza(nomePizza, borda, massa, tamanho, preço, categoria_id) values ("Atum","NÃO", "fina", "pequena", 35.00,2);
select * from tb_pizza where preço > 45.00;
select * from tb_pizza where preço between 29 and 60;
select * from tb_pizza where nomePizza like "%c%";
select tb_categoria.nome, tb_categoria.localidade, tb_categoria.tipo, tb_pizza.nomePizza, tb_pizza.borda, tb_pizza.massa, tb_pizza.tamanho, tb_pizza.preço, tb_pizza.categoria_id
from tb_pizza inner join tb_categoria
on tb_pizza.categoria_id = tb_categoria.id;
select * from tb_pizza where categoria_id = 1; |
-- phpMyAdmin SQL Dump
-- version 4.2.11
-- http://www.phpmyadmin.net
--
-- Φιλοξενητής: 127.0.0.1
-- Χρόνος δημιουργίας: 07 Δεκ 2015 στις 12:42:54
-- Έκδοση διακομιστή: 5.6.21
-- Έκδοση PHP: 5.6.3
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Βάση δεδομένων: `secretary`
--
-- --------------------------------------------------------
--
-- Δομή πίνακα για τον πίνακα `application`
--
CREATE TABLE IF NOT EXISTS `application` (
`CodeId` smallint(4) NOT NULL,
`StudentId` varchar(10) NOT NULL,
`ApplictionId` smallint(2) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=greek;
--
-- Άδειασμα δεδομένων του πίνακα `application`
--
INSERT INTO `application` (`CodeId`, `StudentId`, `ApplictionId`) VALUES
(1, 'up1000', 5),
(2, 'up2015', 2),
(3, 'up4321', 2),
(4, 'up2340', 3),
(5, 'up1623', 4),
(6, 'up2245', 1),
(7, 'up2156', 4),
(8, 'up3210', 2),
(9, 'up3216', 7),
(10, 'up1225', 6),
(11, 'up1123', 5),
(12, 'up1180', 6),
(13, 'up1240', 6),
(14, 'up3223', 4),
(15, 'up1089', 2),
(16, 'up1057', 4),
(17, 'up1230', 4),
(18, 'up1235', 5),
(19, 'up2248', 2),
(20, 'up1057', 1),
(21, 'up1230', 3);
-- --------------------------------------------------------
--
-- Δομή πίνακα για τον πίνακα `certificate`
--
CREATE TABLE IF NOT EXISTS `certificate` (
`CertificateID` smallint(2) NOT NULL,
`CertificateName` varchar(30) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=greek;
--
-- Άδειασμα δεδομένων του πίνακα `certificate`
--
INSERT INTO `certificate` (`CertificateID`, `CertificateName`) VALUES
(1, 'Στρατολογία'),
(2, 'ΤΣΜΕΔΕ'),
(3, 'Επικυρωμένη Φωτοτυπία '),
(4, 'Εφορία'),
(5, 'Φοιτητική Εστία'),
(6, 'Ξένες Αρχές'),
(7, 'Απλή Φωτοτυπία ');
-- --------------------------------------------------------
--
-- Δομή πίνακα για τον πίνακα `students`
--
CREATE TABLE IF NOT EXISTS `students` (
`StudentsId` varchar(10) NOT NULL,
`LastName` varchar(100) NOT NULL,
`FirstName` varchar(100) NOT NULL,
`FirstYear` int(5) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=greek;
--
-- Άδειασμα δεδομένων του πίνακα `students`
--
INSERT INTO `students` (`StudentsId`, `LastName`, `FirstName`, `FirstYear`) VALUES
('up1000', 'ΝΙΚΟΛΟΠΟΥΛΟΣ', 'ΔΗΜΗΤΡΙΟΣ', 2002),
('up1125', 'ΕΥΘΥΜΙΟΥ', 'ΠΑΝΑΓΙΩΤΗΣ', 2000),
('up1225', 'ΚΑΝΕΛΛΟΠΟΥΛΟΣ', 'ΠΕΤΡΟΣ', 2001),
('up1623', 'ΠΑΥΛΟΠΟΥΛΟΣ', 'ΒΑΣΙΛΕΙΟΣ', 2014),
('up2015', 'ΣΓΟΥΡΙΔΗ', 'ΜΑΡΙΑ', 2012),
('up2256', 'ΡΟΥΒΑΛΗΣ', 'ΑΝΔΡΕΑΣ', 2011),
('up2340', 'ΠΑΠΑΚΩΣΤΑ', 'ΕΛΕΝΗ', 2014),
('up2341', 'ΛΑΜΠΡΙΔΗΣ', 'ΚΩΝΣΤΑΝΤΙΝΟΣ', 2013),
('up3210', 'ΒΓΕΝΟΠΟΥΛΟΣ', 'ΗΛΙΑΣ', 2012),
('up3216', 'ΘΩΜΟΠΟΥΛΟΣ', 'ΓΕΩΡΓΙΟΣ', 2004),
('up2156', 'ΣΩΤΗΡΙΟΥ', 'ΠΕΡΙΚΛΗΣ', 2010),
('up3223', 'ΜΗΤΡΟΠΟΥΛΟΣ', 'ΧΡΟΝΗΣ', 2008),
('up1057', 'ΡΟΔΟΠΟΥΛΟΣ', 'ΓΕΩΡΓΙΟΣ', 2011),
('up1230', 'ΣΤΑΥΡΟΠΟΥΛΟΣ', 'ΧΡΗΣΤΟΣ', 2009),
('up442', 'ΠΑΠΑΔΗΜΗΤΡΙΟΥ', 'ΜΥΡΤΩ', 2013),
('up4549', 'ΒΟΥΛΓΑΡΗ', 'ΕΛΕΝΗ', 2014);
--
-- Ευρετήρια για άχρηστους πίνακες
--
--
-- Ευρετήρια για πίνακα `application`
--
ALTER TABLE `application`
ADD PRIMARY KEY (`CodeId`);
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
-- t_alarm_type
DROP TABLE IF EXISTS t_alarm_type;
CREATE TABLE t_alarm_type
(
alarm_type bigint NOT NULL COMMENT '告警类型',
alarm_name varchar(128) NOT NULL COMMENT '告警类型名称',
alarm_level tinyint(4) unsigned NOT NULL COMMENT '告警等级',
CONSTRAINT pk_t_alarm_type PRIMARY KEY(alarm_type)
)COMMENT '告警类型表'; |
-- MySQL dump 10.13 Distrib 5.7.9, for Win64 (x86_64)
--
-- Host: 127.0.0.1 Database: thukieng
-- ------------------------------------------------------
-- Server version 5.7.14-log
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `comment`
--
DROP TABLE IF EXISTS `comment`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `comment` (
`comment_id` int(11) NOT NULL AUTO_INCREMENT,
`post_id` int(11) NOT NULL,
`comment_parent` int(11) DEFAULT NULL,
`comment_content` text COLLATE utf8_unicode_ci NOT NULL,
`name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`email` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`comment_id`),
KEY `pk_comment_post_idx` (`post_id`),
KEY `pk_comment_comment_idx` (`comment_parent`),
CONSTRAINT `pk_comment_comment` FOREIGN KEY (`comment_parent`) REFERENCES `comment` (`comment_id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `pk_comment_post` FOREIGN KEY (`post_id`) REFERENCES `post` (`post_id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `comment`
--
LOCK TABLES `comment` WRITE;
/*!40000 ALTER TABLE `comment` DISABLE KEYS */;
/*!40000 ALTER TABLE `comment` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2017-11-18 18:40:21
|
drop database if exists shop;
create database shop default character set utf8;
use shop;
drop table if exists category;
create table category
(
/* 类别编号,自动增长 */
id int not null auto_increment,
/* 类别名称 */
type varchar(20),
/* 类别是否为热点类别,热点类别才有可能显示在首页 */
hot bool default false,
/* 设置类别编号为主键 */
primary key (id)
);
select * from category;
insert into td_user(USERNAME,PASSWORD,Phuone,MONEY,ROLE,IOCN,CREATETIME) values();
insert into category(type,hot,u_id) values('男装',0,1);
DELETE FROM Category WHERE id in (4)
select product0_.id as id1_0_, category1_.id as id0_1_, product0_.name as name1_0_, product0_.price as price1_0_, product0_.pic as pic1_0_, product0_.remark as remark1_0_, product0_.xremark as xremark1_0_, product0_.date as date1_0_, product0_.commend as commend1_0_, product0_.open as open1_0_, product0_.cid as cid1_0_, category1_.type as type0_1_, category1_.hot as hot0_1_, category1_.u_id as u4_0_1_ from shop.product product0_ left outer join category category1_ on product0_.cid=category1_.id where product0_.name like % % limit 5
select
product0_.id as id1_0_,
category1_.id as id0_1_,
product0_.name as name1_0_,
product0_.price as price1_0_,
product0_.pic as pic1_0_,
product0_.remark as remark1_0_,
product0_.xremark as xremark1_0_,
product0_.date as date1_0_,
product0_.commend as commend1_0_,
product0_.open as open1_0_,
product0_.cid as cid1_0_,
category1_.type as type0_1_,
category1_.hot as hot0_1_,
category1_.u_id as u4_0_1_
from
shop.product product0_
left outer join
category category1_
on product0_.cid=category1_.id
where
product0_.name like "% %" limit 8
insert into category(type,hot,aid) values('男装',0,1);
select * from category;
|
select base_schoolid
--,lunchstatus
,sum(membership_days)
,sum(days_present)
,ROUND(sum(days_present) / sum(membership_days),2) * 100 AS ada
from
(select base_studentid
,base_schoolid
,base_grade_level
,lastfirst
,lunchstatus
,(absences_undoc + absences_doc) as absences
,membership_days
--days present
,membership_days - (absences_undoc + absences_doc) as days_present
from
(select base_studentid
,base_schoolid
,base_grade_level
,lastfirst
,lunchstatus
,absences_undoc
,absences_doc
,sum(mem_reg.studentmembership) as membership_days
from
(select base_studentid
,base_schoolid
,base_grade_level
,lastfirst
,lunchstatus
,sum(case
when att_code = 'A'
then 1
else 0
end) as absences_undoc
,sum(case
when att_code = 'AD'
then 1
when att_code = 'D'
then 1
else 0
end) as absences_doc
,sum(case
when att_code = 'T'
then 1
else 0
end) as tardies_reg
,sum(case
when att_code = 'T10'
then 1
else 0
end) as tardies_T10
,sum(case
when att_code = 'S'
then 1
else 0
end) as ISS
,sum(case
when att_code = 'OS'
then 1
else 0
end) as OSS
from
(select base_studentid
,base_schoolid
,base_grade_level
,s.lastfirst
,upper(s.lunchstatus) as lunchstatus
,psad.att_date
,psad.att_code
from
(select base_studentid
,base_schoolid
,base_grade_level
from
(select re.studentid as base_studentid
,re.schoolid as base_schoolid
,re.grade_level as base_grade_level
--the row number function assigns a number to ALL the re-entry events for each student in the query
--so if a student transfers in and out multiple times during the year, these will be numbered 1,2,3 etc.
--by sorting by exit date descending, we put them in order from most recent - oldest.
--turning this into a subquery allows us to take only rn = 1, ie the 'last' re-entry event of the year.
,row_number() over(partition by re.studentid order by re.exitdate desc) as rn
from reenrollments re
where re.entrydate >= '01-AUG-11' and re.exitdate < '30-JUL-12' and (re.exitdate - re.entrydate) > 0)
where rn = 1
union all
--get the students who TRANSFERRED mid year last year.
--logic here is to decode by entry date & enroll status
--excluding schoolid 999999 makes sure that students who were transferred to 'graduated students'
--don't show up in this query.
select students.id as base_studentid
,students.schoolid as base_schoolid
,students.grade_level as base_grade_level
from students
where students.entrydate > '01-AUG-11' and students.entrydate < '28-JUN-12'
and students.enroll_status > 0 and students.exitdate > '01-AUG-11' and students.schoolid != 999999
and (students.exitdate - students.entrydate) > 0)
left outer join students s on base_studentid = s.id
left outer join PS_ATTENDANCE_DAILY psad on base_studentid = psad.studentid
and psad.att_date >= '01-AUG-11'
and psad.att_date < '01-JUL-12'
and psad.att_code is not null)
group by base_studentid, base_schoolid, base_grade_level, lastfirst, lunchstatus)
left outer join pssis_membership_reg mem_reg on base_studentid = mem_reg.studentid
and mem_reg.calendardate > '01-AUG-11'
and mem_reg.calendardate <= '01-JUL-12'
and mem_reg.calendarmembership = 1
group by base_studentid, base_schoolid, base_grade_level, lastfirst, lunchstatus, absences_undoc, absences_doc)
where membership_days > 0)
group by cube(base_schoolid);
|
alter table profile add column phone integer;
alter table profile add column friend_request integer; |
USE burgers_db;
INSERT INTO burgers(burger_name, devoured) VALUES ("garden burger", FALSE);
INSERT INTO burgers(burger_name, devoured) VALUES ("turkey burger", FALSE);
INSERT INTO burgers(burger_name, devoured) VALUES ("triple cheeseburger", FALSE); |
CREATE OR REPLACE FUNCTION zerobyte.ZEROBYTE_TO_ARRAY_BOOL(a ARRAY< STRUCT< _ STRUCT< _ STRUCT< _ INT64 >
> > >)
AS (
ARRAY(
SELECT
zerobyte.ZEROBYTE_TO_BOOL(_)
FROM
UNNEST(a) WITH OFFSET AS o
ORDER BY o)
);
|
---------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------
--ELIMINAR PERMISO DE FAMILIA EN POPUP ITEM CODE
UPDATE Sam3_Propiedad
SET Activo = 0
WHERE PropiedadID = 90
--Entidad = 25 / Item Code
--Propiedad = familia
UPDATE Sam3_Rel_Perfil_Propiedad_Pagina
SET Activo = 0
WHERE PropiedadID = 90 AND PaginaID = 12
--paginaID = propiedad 90 en ... 12 Cuantificacion y 35 Item code pop up
---------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------
--NO MANDATORIO NUMERO DE CERTIFICADO
UPDATE Sam3_Rel_Perfil_Propiedad_Pagina
SET Requerido = 0
WHERE PropiedadID = 103 AND PaginaID = 12
--PaginaID: 12 Cuantificacion
--EntidadID: 27 Colada
--PropiedadID: 103 numerocertificado |
--CREATE EXTENSION postgres_fdw
/*CREATE SERVER postgres_fdw_server FOREIGN DATA WRAPPER postgres_fdw
OPTIONS (host '10.35.19.30', dbname 'clie_db')
CREATE USER MAPPING FOR PUBLIC SERVER postgres_fdw_server
OPTIONS (password '')
CREATE FOREIGN TABLE fdw_newsales (greeting TEXT)
SERVER postgres_fdw_server
OPTIONS (table_name 'newsales')
*/ |
/*
** This script creates the tables for this lattice example.
**
*/
/* A person table - for order picker */
-- DROP TABLE IF EXISTS `person`;
CREATE TABLE `person` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`full_name` varchar(100) NOT NULL,
`date_started` DATE,
`start_time` TIME,
`end_time` TIME,
`notes` TEXT,
PRIMARY KEY( `id` )
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1
;
/* A priority table - for orders */
-- DROP TABLE IF EXISTS `priority`;
CREATE TABLE `priority` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`description` varchar(100) NOT NULL,
PRIMARY KEY( `id` )
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1
;
/* A status table - for orders and lines */
-- DROP TABLE IF EXISTS `status`;
CREATE TABLE `status` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`description` varchar(100) NOT NULL,
PRIMARY KEY( `id` )
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1
;
/* An item table - for order lines */
-- DROP TABLE IF EXISTS `item`;
CREATE TABLE `item` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`description` varchar(100) NOT NULL,
`unit_price` float NOT NULL,
PRIMARY KEY( `id` )
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1
;
/* The customers table */
-- DROP TABLE IF EXISTS `customers`;
CREATE TABLE `customers` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`customer_name` varchar(100) NOT NULL,
`contact_name` varchar(100) NOT NULL,
`contact_address` varchar(100) NOT NULL,
PRIMARY KEY( `id` )
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1
;
/* The orders table */
-- DROP TABLE IF EXISTS `orders`;
CREATE TABLE `orders` (
`order_no` int(11) NOT NULL AUTO_INCREMENT,
`order_datetime` datetime NOT NULL,
`customer_id` int(11) NOT NULL,
`priority` int(11) NOT NULL,
`picker` int(11) NOT NULL,
`order_status` int(11) NOT NULL,
PRIMARY KEY( `order_no` ),
CONSTRAINT `order_customer_fk` FOREIGN KEY (`customer_id`) REFERENCES `customers` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1
;
/* The order lines table */
-- DROP TABLE IF EXISTS `order_lines`;
CREATE TABLE `order_lines` (
`order_line_no` int(11) NOT NULL AUTO_INCREMENT,
`order_no` int(11) NOT NULL,
`seq_no` int(11) NOT NULL,
`item_id` int(11) NOT NULL,
`quantity` int(11) NOT NULL,
`line_status` int(11) NOT NULL,
PRIMARY KEY( `order_line_no` ),
CONSTRAINT `orders` FOREIGN KEY (`order_no`) REFERENCES `orders` (`order_no`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1
;
/* DB Changes
-- Create the customers table.
INSERT INTO customers( `customer_name`, `contact_name`, `contact_address` ) VALUES ( 'The Empire', 'Darth Vader', 'The Death Star' );
INSERT INTO customers( `customer_name`, `contact_name`, `contact_address` ) VALUES ( 'Morris Garages', 'Mr Morris', 'On the corner' );
INSERT INTO customers( `customer_name`, `contact_name`, `contact_address` ) VALUES ( 'Jane Smith Ltd', 'Jane Smith', '51 The Street' );
INSERT INTO customers( `customer_name`, `contact_name`, `contact_address` ) VALUES ( 'Appollo Ltd', 'Mr Stephens', '52 The Street' );
INSERT INTO customers( `customer_name`, `contact_name`, `contact_address` ) VALUES ( 'Zeta Ltd', 'Mrs Quimby', '53 The Street' );
ALTER TABLE orders DROP COLUMN customer;
ALTER TABLE orders ADD COLUMN customer_id INT(11) AFTER `order_datetime`;
ALTER TABLE orders ADD CONSTRAINT `order_customer_fk` FOREIGN KEY (`customer_id`) REFERENCES `customers` (`id`);
UPDATE orders SET customer_id = ( SELECT `id` FROM `customers` ORDER BY `id` LIMIT 1);
ALTER TABLE orders MODIFY COLUMN customer_id INT(11) NOT NULL;
--
-- Create the person table, then...
INSERT INTO person( `full_name`, `date_started` ) VALUES ( 'Glenn Jenkins', NOW() ), ( 'John Smith', NOW() ), ( 'Jane Jones', NOW() ), ( 'Sarah Evans', NOW() );
-- Create the priority table, then...
INSERT INTO `priority` ( `description` ) VALUES ( 'Low' ), ( 'Medium' ), ( 'High' );
-- Create the status table, then...
INSERT INTO `status` ( `description` ) VALUES ( 'Open' ), ( 'Pending' ), ( 'Closed' ), ( 'Despatched' ), ( 'Canceled' );
-- Create the item table, then...
INSERT INTO `item` ( `description` ) VALUES ( 'Lawn mower' ), ( 'Kettle' ), ( 'Scooter' ), ( 'Plaster' ), ( 'Blank CD' );
ALTER TABLE `orders` DROP COLUMN `picker`;
ALTER TABLE `orders` ADD COLUMN `picker` int(11) NOT NULL AFTER `customer_id`;
UPDATE `orders` SET picker = ( SELECT MIN( id ) FROM person );
UPDATE `orders` SET priority = ( SELECT MIN( id ) FROM priority );
ALTER TABLE `orders` ADD COLUMN `order_status` int(11) NOT NULL;
UPDATE `orders` SET order_status = ( SELECT MIN( id ) FROM status );
ALTER TABLE `order_lines` DROP COLUMN `item_description`;
ALTER TABLE `order_lines` ADD COLUMN `item_id` int(11) NOT NULL AFTER `seq_no`;
UPDATE `order_lines` SET `item_id` = ( SELECT MIN( id ) FROM item );
ALTER TABLE `order_lines` ADD COLUMN `line_status` int(11) NOT NULL;
UPDATE `order_lines` SET `line_status` = ( SELECT MIN( id ) FROM status );
--
ALTER TABLE `person` ADD `start_time` TIME;
ALTER TABLE `person` ADD `end_time` TIME;
ALTER TABLE `person` ADD `notes` TEXT;
ALTER TABLE `item` ADD `unit_price` float NOT NULL;
*/
|
ALTER TABLE courses ALTER COLUMN slug TYPE varchar(30);
|
TRUNCATE TABLE FS_TAX_REGION_RATE_T
/
INSERT INTO FS_TAX_REGION_RATE_T (TAX_REGION_CD,TAX_RATE_EFFECTIVE_DT,OBJ_ID,VER_NBR,TAX_RATE)
VALUES ('05PERCNTY',STR_TO_DATE( '20080701000000', '%Y%m%d%H%i%s' ),'5ACF22CFC6094AB0E0404F8189D87AB9',1.0,0.05)
/
INSERT INTO FS_TAX_REGION_RATE_T (TAX_REGION_CD,TAX_RATE_EFFECTIVE_DT,OBJ_ID,VER_NBR,TAX_RATE)
VALUES ('1',STR_TO_DATE( '10080701000000', '%Y%m%d%H%i%s' ),'5ACF22CFC6044AB0E0404F8189D87AB9',1.0,0.0050)
/
INSERT INTO FS_TAX_REGION_RATE_T (TAX_REGION_CD,TAX_RATE_EFFECTIVE_DT,OBJ_ID,VER_NBR,TAX_RATE)
VALUES ('10',STR_TO_DATE( '20080701000000', '%Y%m%d%H%i%s' ),'5ACF22CFC60D4AB0E0404F8189D87AB9',1.0,0.1721)
/
INSERT INTO FS_TAX_REGION_RATE_T (TAX_REGION_CD,TAX_RATE_EFFECTIVE_DT,OBJ_ID,VER_NBR,TAX_RATE)
VALUES ('11',STR_TO_DATE( '20080701000000', '%Y%m%d%H%i%s' ),'5ACF22CFC60E4AB0E0404F8189D87AB9',1.0,0.25)
/
INSERT INTO FS_TAX_REGION_RATE_T (TAX_REGION_CD,TAX_RATE_EFFECTIVE_DT,OBJ_ID,VER_NBR,TAX_RATE)
VALUES ('12',STR_TO_DATE( '20080701000000', '%Y%m%d%H%i%s' ),'5ACF22CFC60F4AB0E0404F8189D87AB9',1.0,0.07)
/
INSERT INTO FS_TAX_REGION_RATE_T (TAX_REGION_CD,TAX_RATE_EFFECTIVE_DT,OBJ_ID,VER_NBR,TAX_RATE)
VALUES ('13',STR_TO_DATE( '20080701000000', '%Y%m%d%H%i%s' ),'5ACF22CFC6104AB0E0404F8189D87AB9',1.0,0.15)
/
INSERT INTO FS_TAX_REGION_RATE_T (TAX_REGION_CD,TAX_RATE_EFFECTIVE_DT,OBJ_ID,VER_NBR,TAX_RATE)
VALUES ('14',STR_TO_DATE( '20080701000000', '%Y%m%d%H%i%s' ),'5ACF22CFC6114AB0E0404F8189D87AB9',1.0,0.2)
/
INSERT INTO FS_TAX_REGION_RATE_T (TAX_REGION_CD,TAX_RATE_EFFECTIVE_DT,OBJ_ID,VER_NBR,TAX_RATE)
VALUES ('15',STR_TO_DATE( '20080701000000', '%Y%m%d%H%i%s' ),'6B64AB2CF6079938E0404F8189D824B6',1.0,0.0025)
/
INSERT INTO FS_TAX_REGION_RATE_T (TAX_REGION_CD,TAX_RATE_EFFECTIVE_DT,OBJ_ID,VER_NBR,TAX_RATE)
VALUES ('2',STR_TO_DATE( '20020101000000', '%Y%m%d%H%i%s' ),'5ACF22CFC6054AB0E0404F8189D87AB9',1.0,0.0825)
/
INSERT INTO FS_TAX_REGION_RATE_T (TAX_REGION_CD,TAX_RATE_EFFECTIVE_DT,OBJ_ID,VER_NBR,TAX_RATE)
VALUES ('3',STR_TO_DATE( '20080701000000', '%Y%m%d%H%i%s' ),'5ACF22CFC6064AB0E0404F8189D87AB9',1.0,0.015)
/
INSERT INTO FS_TAX_REGION_RATE_T (TAX_REGION_CD,TAX_RATE_EFFECTIVE_DT,OBJ_ID,VER_NBR,TAX_RATE)
VALUES ('4',STR_TO_DATE( '20080701000000', '%Y%m%d%H%i%s' ),'5ACF22CFC6074AB0E0404F8189D87AB9',1.0,0.01)
/
INSERT INTO FS_TAX_REGION_RATE_T (TAX_REGION_CD,TAX_RATE_EFFECTIVE_DT,OBJ_ID,VER_NBR,TAX_RATE)
VALUES ('5',STR_TO_DATE( '20080701000000', '%Y%m%d%H%i%s' ),'5ACF22CFC6084AB0E0404F8189D87AB9',1.0,0.56)
/
INSERT INTO FS_TAX_REGION_RATE_T (TAX_REGION_CD,TAX_RATE_EFFECTIVE_DT,OBJ_ID,VER_NBR,TAX_RATE)
VALUES ('7',STR_TO_DATE( '20080701000000', '%Y%m%d%H%i%s' ),'5ACF22CFC60A4AB0E0404F8189D87AB9',1.0,0.2)
/
INSERT INTO FS_TAX_REGION_RATE_T (TAX_REGION_CD,TAX_RATE_EFFECTIVE_DT,OBJ_ID,VER_NBR,TAX_RATE)
VALUES ('8',STR_TO_DATE( '20080701000000', '%Y%m%d%H%i%s' ),'5ACF22CFC60B4AB0E0404F8189D87AB9',1.0,0.175)
/
INSERT INTO FS_TAX_REGION_RATE_T (TAX_REGION_CD,TAX_RATE_EFFECTIVE_DT,OBJ_ID,VER_NBR,TAX_RATE)
VALUES ('9',STR_TO_DATE( '20080701000000', '%Y%m%d%H%i%s' ),'5ACF22CFC60C4AB0E0404F8189D87AB9',1.0,0.1125)
/
|
CREATE FUNCTION F11(@empl_codigo NUMERIC(6)) RETURNS INT
BEGIN
RETURN (SELECT COUNT(DISTINCT empl_codigo) + ISNULL(SUM(dbo.F11(empl_codigo)), 0)
FROM Empleado
WHERE empl_jefe = @empl_codigo)
END;
SELECT dbo.F11(empl_codigo) FROM Empleado; |
-- database: presto; groups: tpch; tables: customer
SELECT c_count,
count(*) AS custdist
FROM (SELECT c_custkey,
count(o_orderkey)
FROM customer
LEFT OUTER JOIN orders ON
c_custkey = o_custkey
AND o_comment NOT LIKE '%special%requests%'
GROUP BY c_custkey) AS c_orders (c_custkey, c_count)
GROUP BY c_count
ORDER BY custdist DESC,
c_count DESC
|
-- COLUMNS
SELECT VST_RPT.pt_id AS [Account_Number]
, VST_RPT.unit_seq_no AS [Unit_Seq_No]
--, VST_RPT.from_file_ind AS [From_File_Ind]
, LTRIM(RTRIM(VST_RPT.vst_med_rec_no)) AS [Medical_Record_Number]
, CONVERT(VARCHAR, VST_RPT.adm_date, 101) AS [Admit_Date/Date_of_Service]
, CONVERT(VARCHAR, VST_RPT.adm_date, 101) AS [Registration_Date]
, CONVERT(VARCHAR, VST_RPT.dsch_date, 101) AS [Discharge_Date]
, CONVERT(VARCHAR, VST_RPT.bd_wo_date, 101) AS [Charge_Off_Date]
, CONVERT(VARCHAR, L_PT_PAY.Last_Pt_Pymt, 101) AS [Last_Pt_Pay_Date]
, ISNULL(LEFT(VST_RPT.prim_pyr_cd, 1), '') AS [Financial_Class]
, Financial_Class_Description = (
SELECT CASE
WHEN LTRIM(RTRIM(LEFT(VST_RPT.prim_pyr_cd, 1))) = 'A' THEN 'Medicare'
WHEN LTRIM(RTRIM(LEFT(VST_RPT.prim_pyr_cd, 1))) = 'B' THEN 'Blue Cross'
WHEN LTRIM(RTRIM(LEFT(VST_RPT.prim_pyr_cd, 1))) = 'C' THEN 'Workers Comp'
WHEN LTRIM(RTRIM(LEFT(VST_RPT.prim_pyr_cd, 1))) = 'D' THEN 'DDD'
WHEN LTRIM(RTRIM(LEFT(VST_RPT.prim_pyr_cd, 1))) = 'E' THEN 'Medicare Mgd'
WHEN LTRIM(RTRIM(LEFT(VST_RPT.prim_pyr_cd, 1))) = 'I' THEN 'Medicaid Mgd'
WHEN LTRIM(RTRIM(LEFT(VST_RPT.prim_pyr_cd, 1))) = 'K' THEN 'HMO'
WHEN LTRIM(RTRIM(LEFT(VST_RPT.prim_pyr_cd, 1))) = 'M' THEN 'Blue Cross'
WHEN LTRIM(RTRIM(LEFT(VST_RPT.prim_pyr_cd, 1))) = 'N' THEN 'No Fault'
WHEN LTRIM(RTRIM(LEFT(VST_RPT.prim_pyr_cd, 1))) = 'P' THEN 'PPP'
WHEN LTRIM(RTRIM(LEFT(VST_RPT.prim_pyr_cd, 1))) = 'S' THEN 'Blue Cross'
WHEN LTRIM(RTRIM(LEFT(VST_RPT.prim_pyr_cd, 1))) = 'W' THEN 'Medicaid'
WHEN LTRIM(RTRIM(LEFT(VST_RPT.prim_pyr_cd, 1))) = 'X' THEN 'Commercial'
WHEN LTRIM(RTRIM(LEFT(VST_RPT.prim_pyr_cd, 1))) = 'Z' THEN 'Medicare'
WHEN VST_RPT.prim_pyr_cd IS NULL THEN 'Self Pay'
ELSE ''
END
)
, DATEDIFF(MONTH, VST_RPT.vst_start_date, GETDATE()) AS [Acct_Age]
, DATEDIFF(MONTH, VST_RPT.vst_end_date, VST_RPT.bd_wo_date) AS [Age_From_Dsch_When_Xfrd_to_BD]
, DATEDIFF(MONTH, VST_RPT.bd_wo_date, MJRF.End_Collect_Dtime) AS [Time_In_BD]
, DATEDIFF(MONTH, VST_RPT.vst_end_date, VST_RPT.bd_wo_date) +
DATEDIFF(MONTH, VST_RPT.bd_wo_date, MJRF.End_Collect_Dtime) AS [Age_When_Collect_Exhaust]
, '111704595' AS [Facility_Tax_ID_No]
, '' AS [Occurance_Code]
, 'Brookhaven Memorial Hospital' AS [Facility_Name]
, VST_RPT.rpt_name AS [Patient_Name]
, PTACCTV.Pt_SSA_No AS [Patient_Social_Security_Number]
, CONVERT(VARCHAR, PTACCTV.Pt_Birthdate, 101) AS [Patient_Date_of_Birth]
, VST_RPT.gender_cd AS [Patient_Gender]
, MARITAL_STS.marital_sts_desc AS [Patient_Marital_Status]
, pt_addr_line1 AS [Patient_Address_Line_One]
, '' AS [Patient_Address_Line_Two]
, pt_addr_line2 AS [Patient_City]
, pt_addr_line3 AS [Patient_State]
, PTACCTV.Pt_Zip_Cd AS [Patient_Zip]
, '' AS [Patient_Mail_Return_Flag]
, VST_RPT.pt_rpt_phone_no AS [Patient_Home_Phone]
, SUBSTRING(XXX.phone_no, 1, 3) + '-' +
SUBSTRING(XXX.PHONE_NO, 4, 3) + '-' +
SUBSTRING(XXX.PHONE_NO, 7, 4) AS [Patient_Employer_Phone]
, '' AS [Patient_Cell_Phone]
, VST_RPT.pt_empl_name AS [Patient_Employer_Name]
, SUBSTRING(XXX.phone_no, 1, 3) + '-' +
SUBSTRING(XXX.PHONE_NO, 4, 3) + '-' +
SUBSTRING(XXX.PHONE_NO, 7, 4) AS [Patient_Work_Employer_Phone]
, XXX.addr_line1 AS [Patient_Employer_Address_Line_One]
, '' AS [Patient_Employer_Address_Line_Two]
, XXX.addr_line2 AS [Patient_Employer_City]
, XXX.addr_line3 AS [Patient_Employer_State]
, XXX.postal_cd AS [Patient_Employer_Zip]
, vst_rpt.guar_last_name + ' ,' + VST_RPT.guar_first_name AS [Guarantor_Name]
, '' AS [Guarantor_Relationship_To_Patient]
, YYY.nhs_id_no AS [Guarantor_Social_Security_Number]
, CONVERT(VARCHAR, YYY.guar_birth_dtime, 101) AS [Guarantor_Date_Of_Birth]
, '' AS [Guarantor_Gender]
, '' AS [Guarantor_Marital_Status]
, YYY.addr_line1 AS [Guarantor_Address_Line_One]
, '' AS [Guarantor_Address_Line_Two]
, YYY.addr_line2 AS [Guarantor_City]
, YYY.addr_line3 AS [Guarantor_State]
, YYY.postal_cd AS [Guarantor_Zip]
, '' AS [Guarantor_Mail_Return_Flag]
, SUBSTRING(YYY.phone_no, 1, 3) + '-' +
SUBSTRING(YYY.PHONE_NO, 4, 3) + '-' +
SUBSTRING(YYY.PHONE_NO, 7, 4) AS [Guarantor_Home_Phone]
, SUBSTRING(WWW.phone_no, 1, 3) + '-' +
SUBSTRING(WWW.PHONE_NO, 4, 3) + '-' +
SUBSTRING(WWW.PHONE_NO, 7, 4) AS [Guarantor_Work_Phone]
, SUBSTRING(WWW.phone_no, 1, 3) + '-' +
SUBSTRING(WWW.PHONE_NO, 4, 3) + '-' +
SUBSTRING(WWW.PHONE_NO, 7, 4) AS [Guarantor_Wrk_Employer_Phone]
, '' AS [Guarantor_Cell_Phone]
, WWW.last_name AS [Guarantor_Employer]
, SUBSTRING(WWW.phone_no, 1, 3) + '-' +
SUBSTRING(WWW.PHONE_NO, 4, 3) + '-' +
SUBSTRING(WWW.PHONE_NO, 7, 4) AS [Guarantor_Employer_Work_Phone]
, WWW.addr_line1 AS [Guarantor_Employer_Address_Line_One]
, '' AS [Guarantor_Employer_Address_Line_Two]
, WWW.addr_line2 AS [Guarantor_Employer_City]
, WWW.addr_line3 AS [Guarantor_Employer_State]
, WWW.postal_cd AS [Guarantor_Employer_Zip]
, SUBSTRING(WWW.phone_no, 1, 3) + '-' +
SUBSTRING(WWW.PHONE_NO, 4, 3) + '-' +
SUBSTRING(WWW.PHONE_NO, 7, 4) AS [Guarantor_Employer_Phone]
, VST_RPT.tot_bal_amt AS [Account_Balance]
, VST_RPT.tot_chg_amt AS [Total_Charges]
, PMT_PIP.tot_pymts_w_pip AS [Total_Payments]
, (
VST_RPT.tot_chg_amt +
PMT_PIP.tot_pymts_w_pip -
VST_RPT.tot_bal_amt
) AS [Total_Adjustments]
, VST_RPT.ins_pay_amt AS [Total_Insurance_Payment]
, (
PMT_PIP.tot_pymts_w_pip -
VST_RPT.ins_pay_amt
) AS [Tot_Pt_Pymts]
, PT_PMTS.Tot_Pt_Pymts AS [Last_Patient_Payment]
, PYR_MSTR.pyr_name AS [Primary_Insurance_Name]
, VST_RPT.ins1_pol_no AS [Primary_Ins_ID_Number]
, VST_RPT.subscr_ins1_grp_id AS [Primary_Insurance_Group_Number]
, '' AS [Primary_Insurance_IPLAN_No]
, INS_INFO.Ins_Name AS [Ins1_Name]
, INS_INFO.Ins_Addr1 AS [Primary_Insurance_Address_Line_One]
, '' AS [Primary_Insurance_Address_Line_Two]
, INS_INFO.Ins_City AS [Primary_Insurance_City]
, INS_INFO.Ins_State AS [Primary_Insurance_State]
, INS_INFO.Ins_Zip AS [Primary_Insurance_Zip]
, INS_INFO.Ins_Tel_No AS [Primary_Insurance_Phone_Number]
, PTACCTV.Pyr2_Co_Plan_Cd
, PTACCTV.Pyr3_Co_Plan_Cd
, PTACCTV.Pyr4_Co_Plan_Cd
, VST_RPT.ins2_pol_no
, VST_RPT.ins3_pol_no
, VST_RPT.ins4_pol_no
, VST_RPT.subscr_ins2_grp_id
, VST_RPT.subscr_ins3_grp_id
, VST_RPT.subscr_ins4_grp_id
--, PTACCTV.Adm_Dr_No
, PRACT_MSTR_A.npi_no AS [Admitting_Physician_NPI]
, PRACT_MSTR_A.pract_rpt_name AS [Admitting_Physician_Name]
--, PTACCTV.Atn_Dr_No
, PRACT_MSTR_B.npi_no AS [Attending_Physician_NPI]
, PRACT_MSTR_B.pract_rpt_name AS [Attending_Physician_Name]
, CONVERT(VARCHAR, VST_RPT.bd_wo_date, 101) AS [Last_Agency_Placed_Date]
, CONVERT(VARCHAR, MJRF.End_Collect_Dtime, 101) AS [Last_Agency_Returned_Date]
, VST_RPT.alt_bd_wo_amt AS [Last_Agency_Placed_Amount]
, (VST_RPT.tot_bal_amt - VST_RPT.alt_bd_wo_amt) AS [Last_Agency_Recovery_Amount]
, '' AS [Last_Agency_Adjustment_Amount]
, '' AS [Last_Agency_Recall_Amount]
, '' AS [Attorney_Name]
, '' AS [Attorney_Address_Line_1]
, '' AS [Attorney_Address_Line_2]
, '' AS [Attorney_City]
, '' AS [Attorney_State]
, '' AS [Attorney_Zip]
, '' AS [Attorney_Phone_Number]
INTO #TEMP_A
-- TABLES AND OR VIEWS
FROM smsmir.vst_rpt AS VST_RPT
LEFT JOIN smsdss.BMH_PLM_PtAcct_V AS PTACCTV
ON VST_RPT.pt_id = PTACCTV.Pt_No
AND VST_RPT.unit_seq_no = PTACCTV.unit_seq_no
LEFT JOIN smsdss.c_Last_Pt_Pymt_v AS L_PT_PAY
ON VST_RPT.pt_id = L_PT_PAY.pt_id
AND VST_RPT.unit_seq_no = L_PT_PAY.unit_seq_no
LEFT JOIN smsdss.c_MJRF_Closed_Accts_v AS MJRF
ON VST_RPT.pt_id = MJRF.acct_no
LEFT JOIN smsdss.marital_sts_mstr AS MARITAL_STS
ON VST_RPT.marital_sts = MARITAL_STS.marital_sts
AND MARITAL_STS.src_sys_id='#PASS0X0'
-- patient information ---
LEFT JOIN smsmir.trn_pers_addr AS ZZZ
ON VST_RPT.pt_id = ZZZ.PT_ID
AND VST_RPT.from_file_ind = ZZZ.from_file_ind
AND ZZZ.pers_type = 'PT'
-- patient employer informaiton ---
LEFT JOIN smsmir.trn_pers_addr AS XXX
ON VST_RPT.pt_id = XXX.PT_ID
AND VST_RPT.from_file_ind = XXX.from_file_ind
AND XXX.pers_type = 'PE'
-- guarantor information --
LEFT JOIN smsmir.trn_pers_addr AS YYY
ON VST_RPT.pt_id = YYY.pt_id
AND VST_RPT.from_file_ind = YYY.from_file_ind
AND YYY.pers_type = 'PG'
-- guarantor employer information --
LEFT JOIN smsmir.trn_pers_addr AS WWW
ON VST_RPT.pt_id = WWW.pt_id
AND VST_RPT.from_file_ind = WWW.from_file_ind
AND WWW.pers_type = 'GE'
LEFT JOIN smsdss.c_tot_pymts_w_pip_v AS PMT_PIP
ON VST_RPT.pt_id = PMT_PIP.pt_id
AND VST_RPT.unit_seq_no = PMT_PIP.unit_seq_no
LEFT JOIN smsdss.c_pt_payments_v AS PT_PMTS
ON VST_RPT.pt_id = PT_PMTS.pt_id
AND VST_RPT.unit_seq_no = PT_PMTS.unit_seq_no
AND PT_PMTS.Pymt_Rank = '1'
LEFT JOIN smsmir.mir_pyr_mstr AS PYR_MSTR
ON VST_RPT.prim_pyr_cd = PYR_MSTR.pyr_cd
LEFT JOIN smsdss.c_ins_user_fields_v AS INS_INFO
ON VST_RPT.pt_id = INS_INFO.pt_id
AND LTRIM(RTRIM(VST_RPT.prim_pyr_cd)) = LTRIM(RTRIM(INS_INFO.pyr_cd))
LEFT JOIN smsmir.mir_pract_mstr AS PRACT_MSTR_A
ON PTACCTV.Adm_Dr_No = PRACT_MSTR_A.pract_no
AND PRACT_MSTR_A.iss_orgz_cd = 'S0X0'
LEFT JOIN smsmir.mir_pract_mstr AS PRACT_MSTR_B
ON PTACCTV.Adm_Dr_No = PRACT_MSTR_B.pract_no
AND PRACT_MSTR_B.iss_orgz_cd = 'S0X0'
-- FILTERS
WHERE VST_RPT.from_file_ind IN (
'4H', '6H'
)
AND VST_RPT.resp_cd IS NULL
AND VST_RPT.bd_wo_date > '2007-12-31'
AND VST_RPT.tot_bal_amt > 0
AND VST_RPT.pt_id IN (
SELECT DISTINCT(acct_no)
FROM smsmir.acct
WHERE FROM_FILE_IND IN (
'4H', '6H'
)
)
-- TESTING --
--AND VST_RPT.pt_id = '000074001264'
--AND vst_rpt.unit_seq_no = '12103144'
-- END TESTING --
OPTION(FORCE ORDER);
-----
SELECT A.*
, INS_INFO.Ins_Name AS [Secondary_Insurance_Name]
, A.ins2_pol_no AS [Secondary_Insurance_ID_Number]
, A.subscr_ins2_grp_id AS [Secondary_Insurance_Group_Number]
, '' AS [Secondary_Insurance_IPlan_Number]
, INS_INFO.Ins_Addr1 AS [Secondary_Insurance_Address_Line_One]
, '' AS [Secondary_Insurance_Address_Line_Two]
, INS_INFO.Ins_City AS [Secondary_Insurance_City]
, INS_INFO.Ins_State AS [Secondary_Insurance_State]
, INS_INFO.Ins_Zip AS [Secondary_Insurance_Zip]
, INS_INFO.Ins_Tel_No AS [Secondary_Insurance_Phone_Number]
INTO #TEMP_B
FROM #TEMP_A AS A
LEFT JOIN smsdss.c_ins_user_fields_v AS INS_INFO
ON A.Account_Number = INS_INFO.pt_id
AND LTRIM(RTRIM(A.PYR2_CO_PLAN_CD)) = LTRIM(RTRIM(INS_INFO.pyr_cd))
;
-----
SELECT B.*
, INS_INFO.Ins_Name AS [Tertiary_Insurance_Name]
, B.ins3_pol_no AS [Tertiary_Insurance_ID_Number]
, B.subscr_ins3_grp_id AS [Tertiary_Insurance_Group_Number]
, '' AS [Tertiary_Insurance_IPlan_Number]
, INS_INFO.Ins_Addr1 AS [Tertiary_Insurance_Address_Line_One]
, '' AS [Tertiary_Insurance_Address_Line_Two]
, INS_INFO.Ins_City AS [Tertiary_Insurance_City]
, INS_INFO.Ins_State AS [Tertiary_Insurance_State]
, INS_INFO.Ins_Zip AS [Tertiary_Insurance_Zip]
, INS_INFO.Ins_Tel_No AS [Tertiary_Insurance_Phone_Number]
INTO #TEMP_C
FROM #TEMP_B AS B
LEFT JOIN smsdss.c_ins_user_fields_v AS INS_INFO
ON B.Account_Number = INS_INFO.pt_id
AND LTRIM(RTRIM(B.PYR3_CO_PLAN_CD)) = LTRIM(RTRIM(INS_INFO.PYR_CD))
;
-----
SELECT C.Account_Number
, C.Unit_Seq_No
, C.Medical_Record_Number
, C.[Admit_Date/Date_of_Service]
, C.Registration_Date
, C.Discharge_Date
, C.Charge_Off_Date
, C.Last_Pt_Pay_Date
, C.Financial_Class
, C.Financial_Class_Description
, C.Acct_Age
, C.Age_From_Dsch_When_Xfrd_to_BD
, C.Time_In_BD
, C.Age_When_Collect_Exhaust
, C.Facility_Name
, C.Occurance_Code
, C.Facility_Name
, C.Patient_Name
, C.Patient_Social_Security_Number
, C.Patient_Date_of_Birth
, C.Patient_Gender
, C.Patient_Marital_Status
, C.Patient_Address_Line_One
, C.Patient_Address_Line_Two
, C.Patient_City
, C.Patient_State
, C.Patient_Zip
, C.Patient_Mail_Return_Flag
, C.Patient_Home_Phone
, C.Patient_Employer_Phone
, C.Patient_Cell_Phone
, C.Patient_Employer_Name
, C.Patient_Work_Employer_Phone
, C.Patient_Employer_Address_Line_One
, C.Patient_Employer_Address_Line_Two
, C.Patient_Employer_City
, C.Patient_Employer_State
, C.Patient_Zip
, C.Guarantor_Name
, C.Guarantor_Relationship_To_Patient
, C.Guarantor_Social_Security_Number
, C.Guarantor_Date_Of_Birth
, C.Guarantor_Gender
, C.Guarantor_Marital_Status
, C.Guarantor_Address_Line_One
, C.Guarantor_Address_Line_Two
, C.Guarantor_City
, C.Guarantor_State
, C.Guarantor_Mail_Return_Flag
, C.Guarantor_Home_Phone
, C.Guarantor_Work_Phone
, C.Guarantor_Wrk_Employer_Phone
, C.Guarantor_Cell_Phone
, C.Guarantor_Employer
, C.Guarantor_Employer_Work_Phone
, C.Guarantor_Employer_Address_Line_One
, C.Guarantor_Employer_Address_Line_Two
, C.Guarantor_Employer_City
, C.Guarantor_Employer_State
, C.Guarantor_Employer_Zip
, C.Guarantor_Employer_Phone
, C.Account_Balance
, C.Total_Charges
, C.Total_Payments
, C.Total_Adjustments
, C.Total_Insurance_Payment
, C.Tot_Pt_Pymts
, C.Last_Patient_Payment
, C.Primary_Insurance_Name
, C.Primary_Ins_ID_Number
, C.Primary_Insurance_Group_Number
, C.Primary_Insurance_IPLAN_No
, C.Ins1_Name
, C.Primary_Insurance_Address_Line_One
, C.Primary_Insurance_Address_Line_Two
, C.Primary_Insurance_City
, C.Primary_Insurance_State
, C.Primary_Insurance_Zip
, C.Primary_Insurance_Phone_Number
, C.Secondary_Insurance_ID_Number
, C.Secondary_Insurance_Group_Number
, C.Secondary_Insurance_IPlan_Number
, C.Secondary_Insurance_Name
, C.Secondary_Insurance_Address_Line_One
, C.Secondary_Insurance_Address_Line_Two
, C.Secondary_Insurance_City
, C.Secondary_Insurance_State
, C.Secondary_Insurance_Zip
, C.Secondary_Insurance_Phone_Number
, C.Tertiary_Insurance_ID_Number
, C.Tertiary_Insurance_Group_Number
, C.Tertiary_Insurance_IPlan_Number
, C.Tertiary_Insurance_Name
, C.Tertiary_Insurance_Address_Line_One
, C.Tertiary_Insurance_Address_Line_Two
, C.Tertiary_Insurance_City
, C.Tertiary_Insurance_State
, C.Tertiary_Insurance_Phone_Number
, C.Admitting_Physician_NPI
, C.Admitting_Physician_Name
, C.Attending_Physician_NPI
, C.Attending_Physician_Name
, '' AS [Last_Agency_Name]
, C.Last_Agency_Placed_Date
, C.Last_Agency_Returned_Date
, C.Last_Agency_Placed_Amount
, C.Last_Agency_Recovery_Amount
, C.Last_Agency_Adjustment_Amount
, C.Last_Agency_Recall_Amount
, C.Attorney_Name
, C.Attorney_Address_Line_1
, C.Attorney_Address_Line_2
, C.Attorney_City
, C.Attorney_State
, C.Attorney_Zip
, C.Attorney_Phone_Number
FROM #TEMP_C AS C
;
-----
--DROP TABLE #TEMP_A, #TEMP_B, #TEMP_C |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.