text: 
  
  DROP TABLE ratings IF EXISTS;
  DROP TABLE posts_tags IF EXISTS;
  DROP TABLE comments IF EXISTS;
  DROP TABLE tags IF EXISTS;
  DROP TABLE posts IF EXISTS;
  DROP TABLE user_settings IF EXISTS;
  DROP TABLE users_roles IF EXISTS;
  DROP TABLE roles IF EXISTS;
  DROP TABLE users IF EXISTS;
  
  
  CREATE TABLE users 
  ( 
    user_id int primary key auto_increment,
    email_id varchar(255) NOT NULL,
    password varchar(50) NOT NULL,
    firstName varchar(50) DEFAULT NULL,
    lastName varchar(50) DEFAULT NULL,
    gender varchar(10) DEFAULT NULL,
    phone varchar(50) DEFAULT NULL,
    dob datetime DEFAULT NULL,
    disabled boolean NULL,
    bio CLOB  NULL,
    UNIQUE KEY (email_id)
  );
  
  CREATE TABLE  user_settings (
    user_id int NOT NULL,
    theme varchar(45) default NULL,
    receive_email_feed boolean default NULL,
    PRIMARY KEY  (user_id),
    CONSTRAINT USER_SETTINGS_USER_ID FOREIGN KEY (user_id) REFERENCES users (user_id)
  );
  
  CREATE TABLE roles (
    role_id int primary key auto_increment,
    role_name varchar(45) NOT NULL,
    description CLOB ,
    UNIQUE KEY  (role_name)
  );
  
  CREATE TABLE users_roles (
    user_id int NOT NULL,
    role_id int NOT NULL,  
    PRIMARY KEY (user_id, role_id),
    CONSTRAINT FKF6CCD9C6432D04C1 FOREIGN KEY (role_id) REFERENCES roles (role_id),
    CONSTRAINT FKF6CCD9C6E857C8A1 FOREIGN KEY (user_id) REFERENCES users (user_id)
  );
  
  
  CREATE TABLE tags (
    tag_id int primary key auto_increment,
    label varchar(45) NOT NULL,
    value varchar(45) NOT NULL,
    description varchar(256) DEFAULT NULL,
    UNIQUE KEY (label)
  );
  
  
  
  CREATE TABLE posts (
    post_id int primary key auto_increment,
    title varchar(255) NOT NULL,
    description CLOB ,
    posted_by int NOT NULL,
    created_on datetime DEFAULT NULL,
    CONSTRAINT FK65E7BD368CCD1E9 FOREIGN KEY (posted_by) REFERENCES users (user_id)
  );
  
  
  CREATE TABLE posts_tags (
    post_id int NOT NULL,
    tag_id int NOT NULL,
     PRIMARY KEY (post_id, tag_id),
    CONSTRAINT FK95F5DD05D9C91C81 FOREIGN KEY (post_id) REFERENCES posts (post_id),
    CONSTRAINT FK95F5DD05F448AFD3 FOREIGN KEY (tag_id) REFERENCES tags (tag_id)
  );
  
  
  CREATE TABLE comments (
    comment_id int primary key auto_increment,
    post_id int NOT NULL,
    message CLOB  NOT NULL,
    posted_by int NOT NULL,
    created_on datetime NOT NULL,
    CONSTRAINT FKDC17DDF468CCD1E9 FOREIGN KEY (posted_by) REFERENCES users (user_id),
    CONSTRAINT FKDC17DDF4D9C91C81 FOREIGN KEY (post_id) REFERENCES posts (post_id)
  );
  
  CREATE TABLE ratings (
    post_id int NOT NULL,
    user_id int NOT NULL,
    rating int NOT NULL,
    PRIMARY KEY (post_id,user_id),
    CONSTRAINT FK3AA08276E857C8A1 FOREIGN KEY (user_id) REFERENCES users (user_id),
    CONSTRAINT FK3AA08276D9C91C81 FOREIGN KEY (post_id) REFERENCES posts (post_id)
  );
  
  
  insert into roles(role_id, role_name, description)
  values
  (1,'Administrator','Administrator'),
  (2,'SuperAdmin','Super Administrator'),
  (3,'Moderator','Moderator'),
  (4,'NormalUser','Normal User');
  
  
  insert  into users(user_id,email_id,password,firstName,lastName,gender,phone,dob,disabled,bio) 
  values 
  (1,'admin@gmail.com','admin','Mr','Administrator','Male',NULL,NULL,NULL,'I am the THE admin'),
  (2,'test@gmail.com','test','Mr','Test','Female',NULL,NULL,1,'I am a tester'),
  (3,'guest@gmail.com','secret','Mr','Guest','Female','922221222545','2013-04-29 00:00:00',0,'Hey, this is Mr Guest'),
  (4,'essie@vaill.com','Essie','Essie','Vaill','Male','123-123-1234','2013-04-29 00:00:00',0,''),
  (5,'cruz@roudabush.com','Cruz','Cruz','Roudabush','Male','123-123-1234','2013-04-29 00:00:00',0,''),
  (6,'billie@tinnes.com','Billie','Billie','Tinnes','Male','123-123-1234','2013-04-29 00:00:00',0,''),
  (7,'zackary@mockus.com','Zackary','Zackary','Mockus','Male','123-123-1234','2013-04-29 00:00:00',0,''),
  (8,'rosemarie@fifield.com','Rosemarie','Rosemarie','Fifield','Male','123-123-1234','2013-04-29 00:00:00',0,''),
  (9,'bernard@laboy.com','Bernard','Bernard','Laboy','Male','123-123-1234','2013-04-29 00:00:00',0,''),
  (10,'sue@haakinson.com','Sue','Sue','Haakinson','Male','123-123-1234','2013-04-29 00:00:00',0,''),
  (11,'valerie@pou.com','Valerie','Valerie','Pou','Male','123-123-1234','2013-04-29 00:00:00',0,''),
  (12,'lashawn@hasty.com','Lashawn','Lashawn','Hasty','Male','123-123-1234','2013-04-29 00:00:00',0,''),
  (13,'marianne@earman.com','Marianne','Marianne','Earman','Male','123-123-1234','2013-04-29 00:00:00',0,''),
  (14,'justina@dragaj.com','Justina','Justina','Dragaj','Male','123-123-1234','2013-04-29 00:00:00',0,''),
  (15,'mandy@mcdonnell.com','Mandy','Mandy','Mcdonnell','Male','123-123-1234','2013-04-29 00:00:00',0,''),
  (16,'conrad@lanfear.com','Conrad','Conrad','Lanfear','Male','123-123-1234','2013-04-29 00:00:00',0,''),
  (17,'cyril@behen.com','Cyril','Cyril','Behen','Male','123-123-1234','2013-04-29 00:00:00',0,'');
  
  
  insert into user_settings(user_id, theme, receive_email_feed)
  values
  (1,'aristo',true),
  (2,'bootstrap',true),
  (3,'afterdark',true),
  (4,'bluesky',true),
  (5,'blitzer',true),
  (6,'home',true),
  (7,'sam',true),
  (8,'aristo',true),
  (9,'aristo',true),
  (10,'aristo',true);
  
  
  insert into users_roles(user_id,role_id)
  values
  (1,1),(1,2),(1,3),(1,4),
  (2,1),(2,2),(2,3),
  (3,1),(3,2),
  (4,1)
  ;
  
  insert  into tags(tag_id,label,value, description)
  values 
  (1,'JavaSE','java-se','Java Programming Language'),
  (2,'JavaEE','java-ee','Java Enterproze Edition'),
  (3,'Spring','spring','Spring Framework'),
  (4,'SpringMVC','springmvc','SpringMVC framework'),
  (5,'Hibernate','hibernate','Hibernate ORM Framework'),
  (6,'Struts','struts','Struts Framework'),
  (7,'JSF','jsf','JSF Framework'),
  (8,'PrimeFaces','primefaces','PrimeFaces UI Component library for JSF'),
  (9,'jQuery','jquery','jQuery: JavaScript framework'),
  (10,'Perl','perl','Perl Programming Language'),
  (11,'Python','python','Python Programming Language');
  
  
  
  insert  into posts(post_id,created_on,description,title,posted_by) 
  values 
  (1,'2013-01-21 00:00:00','PrimeFaces Team is pleased to announce the 3.5.4 Elite release featuring 20+ filed improvements. So far including the previous 3.5.x Elite releases there have been more than 110 improvements over 3.5 release. 3.5.5 focuses on defect fixes and performance improvements.','PrimeFaces Elite 3.5.5 Released',1),
  (2,'2013-01-21 00:00:00','PrimeFaces.NET is the port of PrimeFaces for JSF as an open source rich control suite for ASP.NET WebForms. 0.1 version is the initial release with 13 controls including Accordion, TabView, Spinner, Slider, Panel, Fieldset and more.','PrimeFaces for ASP.NET 0.1 Released',1),
  (3,'2013-01-21 00:00:00','Community powered PrimeFaces Extensions project has reached 0.7 release with various new features, improvements to existing features and defect fixes.','PrimeFaces Extensions 0.7 Released',1),
  (4,'2013-01-21 00:00:00','PrimeFaces 4.0 codename SENTINEL will introduce dragdrop based manipulation support for Tree component.','DragDrop Support for Tree',1),
  (5,'2013-01-21 00:00:00','PrimeUI is back with a brand new release and closer than ever to 1.0 Final. This 0.9 release brings 7 new widgets from PrimeFaces making 27 widgets in total.','PrimeUI 0.9 Released',1),
  (6,'2013-01-21 00:00:00','PrimeTek is pleased to announce the new 0.9.4 release for PrimeFaces Mobile. This version brings new mobile widgets, bug fixes and performance improvements.','PrimeFaces Mobile 0.9.4 Released',1),
  (7,'2013-01-21 00:00:00','March/April 2013 issue of JavaMagazine is out and Kito D. Mann from Virtua Inc. has written a great article on Interportlet Communication with PrimeFaces Push powered by Atmosphere on Liferay.','Responsive Interportlet Communication with Atmosphere and PrimeFaces',1),
  (8,'2013-01-21 00:00:00','REST applications and web services are a great way to connect applications together. REST is a design principle that imposes no constraints on the client except basic HTTP support, which all platforms provide.','Building REST-ful services with Spring',1),
  (9,'2013-01-21 00:00:00','We are pleased to announce that the second milestone for Spring Integration 3.0.0 is now available. 64 issues are resolved, including many improvements and new features','Spring Integration 3.0 Milestone 2 is Now Available',1),
  (10,'2013-01-21 00:00:00','As you may have seen, the first milestone of Spring Framework 4.0 was already announced and with it we have released early WebSocket support.','Spring Framework 4.0 M1: WebSocket Support',1),
  (11,'2013-01-21 00:00:00','We are pleased to announce that, after a long period of internal incubation, we are releasing a foundational framework for asynchronous applications on the JVM which we are calling Reactor. ','Reactor: a foundation for asynchronous applications on the JVM',1),
  (12,'2013-01-21 00:00:00','Spring Data MongoDB provides a feature rich library for writing MongoDB applications in Java. It builds upon the Spring Framework and as such promotes a POJO programming model with a strong emphasis on productivity.','THE SPRING DATA MONGODB PROJECT',1),
  (13,'2013-01-21 00:00:00','Few companies have been quite at the forefront of implementing Spring Integration (Batch & Data etc.) as Incept5, this years VMWare EMEA cloud partner.','SPRING INTEGRATION IN THE WILD',1),
  (14,'2013-01-21 00:00:00','The continuous evolution of both the Spring Framework and the Java EE platform presents us with new challenges and opportunities for collaboration.','JAVA EE SERVICES FOR SPRING APPLICATIONS',1),
  (15,'2013-01-21 00:00:00','EclipseLink 2.5 has been released and is available for download. http://www.eclipse.org/eclipselink/releases/2.5.php','EclipseLink 2.5 Release Available for Download',1),
  (16,'2013-01-21 00:00:00','Did you ever imagine that someday it would be possible to code in the cloud? Create an app, test and debug it and deploy to a production PaaS, entirely in the cloud? Well, the good old desktop days are gone.','3 Online IDEs That Rock',1);
  
  
  insert  into posts_tags(post_id,tag_id) 
  values 
  (1,1),(1,2),(1,3),
  (2,1),(2,9),(2,6),
  (3,3),(3,6),(3,9),
  (4,3),(4,6),(4,9);
  
  
  insert into ratings(post_id,user_id, rating)
  values
  (1,1,2),
  (2,1,3),
  (3,1,5),
  (4,1,1),
  (1,2,3),
  (2,2,1);
  