Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
408
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.72 KB | None | 0 0
  1. create database portal;
  2.  
  3. use portal;
  4.  
  5. create table groups
  6. (
  7. groupid int unsigned not null auto_increment primary key,
  8. groupname char(10) not null
  9. )ENGINE=InnoDB;
  10.  
  11. INSERT INTO groups(groupname) VALUES('admin');
  12. INSERT INTO groups(groupname) VALUES('sales');
  13. INSERT INTO groups(groupname) VALUES('agent');
  14. INSERT INTO groups(groupname) VALUES('customer');
  15.  
  16. create table users
  17. (
  18. uid int unsigned not null auto_increment primary key,
  19. email varchar(30) not null,
  20. passwd char(40) not null,
  21. groupid int unsigned not null references groups(groupid)
  22. )ENGINE=InnoDB;
  23.  
  24. insert into users (email,passwd,groupid) values ('admin@vtgus.com', sha1('123456'), '1');
  25. insert into users (email,passwd,groupid) values ('sales@vtgus.com', sha1('123456'), '2');
  26. insert into users (email,passwd,groupid) values ('agent@vtgus.com', sha1('123456'), '3');
  27. insert into users (email,passwd,groupid) values ('customer@vtgus.com', sha1('123456'), '4');
  28.  
  29. create table orders
  30. (
  31. ordid int unsigned not null auto_increment primary key,
  32. cusid int unsigned not null references users(uid),
  33. manid int unsigned not null references users(uid),
  34. datetime DATETIME
  35. )ENGINE=InnoDB;
  36.  
  37. insert into orders (cusid, manid, datetime) VALUES('1','2',NOW());
  38.  
  39. ALTER TABLE orders AUTO_INCREMENT = 1000;
  40.  
  41. create table products
  42. (
  43. prodid int unsigned not null auto_increment primary key,
  44. prodname varchar(100) not null,
  45. nrcost float(6,2),
  46. mrcost float(6,2),
  47. catid int unsigned not null references catprod(catid)
  48. ) ENGINE=InnoDB;
  49.  
  50. insert into products (prodname,nrcost,mrcost,catid) values ('Polycom 650', '300','35','1');
  51. insert into products (prodname,nrcost,mrcost,catid) values ('Polycom 335', '150','25','1');
  52. insert into products (prodname,nrcost,mrcost,catid) values ('Yealink T20', '70','25','1');
  53. insert into products (prodname,nrcost,mrcost,catid) values ('Yealink T28', '120','30','1');
  54. insert into products (prodname,nrcost,mrcost,catid) values ('Polycom SideCar 200', '200','25','2');
  55. insert into products (prodname,nrcost,mrcost,catid) values ('Yealink Headset', '25','25','2');
  56. insert into products (prodname,nrcost,mrcost,catid) values ('HP 24 Port POE', '300','300','3');
  57. insert into products (prodname,nrcost,mrcost,catid) values ('Sonic Wall TZ 200', '400','400','4');
  58. insert into products (prodname,nrcost,mrcost,catid) values ('Linksys RUO 420', '200','200','4');
  59. insert into products (prodname,nrcost,mrcost,catid) values ('Simultaneos Call', '20','20','5');
  60. insert into products (prodname,nrcost,mrcost,catid) values ('E911', '20','20','5');
  61. insert into products (prodname,nrcost,mrcost,catid) values ('Hosted Seat', '20','20','5');
  62.  
  63. create table purchase
  64. (
  65. ordid int unsigned not null references orders(ordid),
  66. prodid int unsigned not null references products(prodid),
  67. qty int not null,
  68. fprice float(6,2) not null
  69. )ENGINE=InnoDB;
  70.  
  71. insert into purchase (ordid, prodid, qty, fprice) VALUES('1','1','5','100');
  72. insert into purchase (ordid, prodid, qty, fprice) VALUES('1','3','5','40.12');
  73.  
  74.  
  75.  
  76. create table catprod
  77. (
  78. catid int unsigned not null auto_increment primary key,
  79. catname char(30) not null
  80. )ENGINE=InnoDB;
  81.  
  82. insert into catprod (catname) VALUES ('phone');
  83. insert into catprod (catname) VALUES ('accessories');
  84. insert into catprod (catname) VALUES ('switches');
  85. insert into catprod (catname) VALUES ('edge');
  86. insert into catprod (catname) VALUES ('dialtone');
  87.  
  88.  
  89.  
  90.  
  91.  
  92. create table cusdata
  93. (
  94. ordid int not null,
  95. busname varchar(100) not null,
  96. conname varchar(100) not null,
  97. conemail varchar(30) not null,
  98. address1 varchar(100) not null,
  99. address2 varchar(100) not null,
  100. state varchar(5) not null,
  101. zip int not null,
  102. mainphone int not null,
  103. fax int not null
  104. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement