CREATE TABLE bookmarks (
  id int(11) NOT NULL auto_increment,
  users_LOGIN varchar(255) NOT NULL,
  users_USER_TYPE varchar(255) NOT NULL,
  name text,
  url text,
  PRIMARY KEY  (id),
  KEY users_LOGIN (users_LOGIN)
) DEFAULT CHARSET=utf8;

CREATE TABLE cache (
  name varchar(255) NOT NULL,
  value longblob NOT NULL,
  timestamp varchar(10) NOT NULL,
  expired tinyint(1) NOT NULL default '0',
  PRIMARY KEY  (name)
) DEFAULT CHARSET=utf8;

CREATE TABLE calendar (
  id int(11) NOT NULL auto_increment,
  lessons_ID int(11) default '0',
  data text,
  timestamp varchar(10) NOT NULL,
  active tinyint(1) NOT NULL default '1',
  users_LOGIN varchar(255) NOT NULL,
  PRIMARY KEY  (id)
) DEFAULT CHARSET=utf8;


CREATE TABLE chatmessages (
  id int(11) NOT NULL auto_increment,
  users_LOGIN varchar(255) NOT NULL,
  users_USER_TYPE varchar(255) NOT NULL,
  content text,
  timestamp varchar(10) NOT NULL,
  chatrooms_ID int(11) NOT NULL default '0',
  PRIMARY KEY  (id)
) DEFAULT CHARSET=utf8;

CREATE TABLE chatrooms (
  id int(11) NOT NULL auto_increment,
  name varchar(255) NOT NULL,
  create_timestamp varchar(10) NOT NULL,
  users_LOGIN varchar(255) NOT NULL,
  type varchar(255) NOT NULL,
  active tinyint(1) NOT NULL default '1',
  lessons_ID int(11) default NULL,
  PRIMARY KEY  (id)
) DEFAULT CHARSET=utf8;

CREATE TABLE comments (
  id int(11) NOT NULL auto_increment,
  data text NOT NULL,
  users_LOGIN varchar(255) NOT NULL,
  content_ID int(11) NOT NULL default '0',
  timestamp varchar(10) NOT NULL,
  active tinyint(1) NOT NULL default '0',
  PRIMARY KEY  (id)
) DEFAULT CHARSET=utf8;

CREATE TABLE configuration (
  name varchar(255) NOT NULL,
  value text NOT NULL,
  PRIMARY KEY  (name)
) DEFAULT CHARSET=utf8;

CREATE TABLE content (
  id int(11) NOT NULL auto_increment,
  name varchar(255) NOT NULL,
  data longtext,
  parent_content_ID int(11) default '0',
  lessons_ID int(11) default '0',
  timestamp varchar(10) NOT NULL,
  ctg_type varchar(255) NOT NULL,
  active tinyint(1) default '1',
  previous_content_ID int(11) default '0',
  options text default NULL,
  PRIMARY KEY  (id)
) DEFAULT CHARSET=utf8;

CREATE TABLE courses (
  id int(11) NOT NULL auto_increment,
  name varchar(255) NOT NULL,
  directions_ID int(11) NOT NULL default '0',
  info text,
  price float default '0',
  active tinyint(1) NOT NULL default '1',
  languages_NAME varchar(255) NOT NULL,
  metadata text,
  certificate text,
  auto_certificate tinyint(1) default '0',
  certificate_tpl text,
  auto_complete tinyint(1) default '0',
  rules text,
  from_timestamp varchar(255) default '',
  to_timestamp varchar(255) default '',
  shift tinyint(1) default '0',
  certificate_border int(11) default '1',
  logo_position tinyint(4) default '0',
  logo_id int1(11) default 0,
  PRIMARY KEY  (id)
) DEFAULT CHARSET=utf8;

CREATE TABLE current_content (
  content_ID int(11) NOT NULL default '0',
  periods_ID int(11) NOT NULL default '0',
  PRIMARY KEY (content_ID, periods_ID)
) DEFAULT CHARSET=utf8;

CREATE TABLE directions (
  id int(11) NOT NULL auto_increment,
  name varchar(255) NOT NULL,
  active tinyint(1) NOT NULL default '1',
  parent_direction_ID int(11) default 0,
  PRIMARY KEY  (id)
) DEFAULT CHARSET=utf8;

CREATE TABLE done_questions (
  id int(11) NOT NULL auto_increment,
  done_tests_ID int(11) NOT NULL default '0',
  questions_ID int(11) NOT NULL default '0',
  answer text,
  score float default '0',
  timestamp varchar(10) NOT NULL,
  PRIMARY KEY  (id)
) DEFAULT CHARSET=utf8;

CREATE TABLE done_tests (
  id int(11) NOT NULL auto_increment,
  users_LOGIN varchar(255) NOT NULL,
  tests_ID int(11) NOT NULL default '0',
  timestamp varchar(10) NOT NULL,
  score float default '0',
  comments text,
  duration varchar(10) NOT NULL,
  PRIMARY KEY  (id)
) DEFAULT CHARSET=utf8;

CREATE TABLE f_forums (
  id int(11) NOT NULL auto_increment,
  title varchar(255) NOT NULL,
  lessons_ID int(11) NOT NULL default '0',
  parent_id int(11) NOT NULL default '0',
  status varchar(255) NOT NULL default 'public',
  users_LOGIN varchar(255) NOT NULL,
  comments text,
  PRIMARY KEY  (id)
) DEFAULT CHARSET=utf8;

CREATE TABLE f_censored_words (
  word varchar(255) NOT NULL,
  replacement varchar(255) NOT NULL,
  PRIMARY KEY  (word)
) DEFAULT CHARSET=utf8;

CREATE TABLE f_configuration (
  name varchar(255) NOT NULL,
  value varchar(255) NOT NULL,
  PRIMARY KEY  (name)
) DEFAULT CHARSET=utf8;

CREATE TABLE f_folders (
  id int(11) NOT NULL auto_increment,
  name varchar(255) NOT NULL,
  users_LOGIN varchar(255) NOT NULL,
  parent_id int(11) NOT NULL default '0',
  PRIMARY KEY  (id)
) DEFAULT CHARSET=utf8;

CREATE TABLE f_messages (
  id int(11) NOT NULL auto_increment,
  f_topics_ID int(11) NOT NULL default '0',
  title varchar(255) NOT NULL,
  body text NOT NULL,
  timestamp varchar(10) NOT NULL,
  users_LOGIN varchar(255) NOT NULL,
  replyto int(11) NOT NULL default '0',
  rank tinyint(4) NOT NULL default '0',
  PRIMARY KEY  (id)
) DEFAULT CHARSET=utf8;

CREATE TABLE f_personal_messages (
  id int(11) NOT NULL auto_increment,
  users_LOGIN varchar(255) NOT NULL,
  recipient text,
  sender varchar(255) NOT NULL,
  timestamp varchar(10) NOT NULL,
  attachments text,
  title varchar(255) NOT NULL,
  body text NOT NULL,
  f_folders_ID int(11) NOT NULL default '1',
  viewed tinyint(1) NOT NULL default '0',
  priority tinyint(1) NOT NULL default '0',
  PRIMARY KEY  (id)
) DEFAULT CHARSET=utf8;

CREATE TABLE f_poll (
  id int(11) NOT NULL auto_increment,
  title varchar(255) NOT NULL,
  question text NOT NULL,
  options text NOT NULL,
  timestamp_created varchar(10) NOT NULL,
  users_LOGIN varchar(255) NOT NULL,  
  f_forums_ID int(11) NOT NULL default '0',
  timestamp_start varchar(10) NOT NULL,
  timestamp_end varchar(10) NOT NULL,
  views int(11) NOT NULL default '0',
  sticky int(11) NOT NULL default '0',
  comments text,
  PRIMARY KEY  (id)
) DEFAULT CHARSET=utf8;

CREATE TABLE f_topics (
  id int(11) NOT NULL auto_increment,
  f_forums_ID int(11) NOT NULL default '0',
  timestamp varchar(10) NOT NULL,
  title varchar(255) NOT NULL,
  users_LOGIN varchar(255) NOT NULL,
  views int(11) NOT NULL default '0',
  viewed_by text,
  status varchar(255) NOT NULL default 'status',
  sticky varchar(255) NOT NULL default '0',
  comments text,
  PRIMARY KEY  (id)
) DEFAULT CHARSET=utf8;

CREATE TABLE f_users_ranking (
  users_LOGIN varchar(255) NOT NULL,
  rank tinyint(4) NOT NULL default '0',
  PRIMARY KEY  (users_LOGIN)
) DEFAULT CHARSET=utf8;

CREATE TABLE f_users_to_polls (
  f_poll_ID int(11) NOT NULL default '0',
  users_LOGIN varchar(255) NOT NULL,
  vote tinyint(4) NOT NULL default '0',
  timestamp varchar(10) NOT NULL,
  primary key (f_poll_ID, users_LOGIN)
) DEFAULT CHARSET=utf8;

CREATE TABLE glossary_words (
  id int(11) NOT NULL auto_increment,
  name varchar(255) NOT NULL,
  lessons_ID int(11) NOT NULL default '0',
  info text,
  type varchar(255) NOT NULL default 'general',
  active tinyint(1) NOT NULL default '1',
  PRIMARY KEY  (id)
) DEFAULT CHARSET=utf8;

CREATE TABLE languages (
  name varchar(255) NOT NULL,
  active tinyint(1) NOT NULL default '1',
  translation varchar(255),
  PRIMARY KEY  (name)
) DEFAULT CHARSET=utf8;

CREATE TABLE lessons (
  id int(11) NOT NULL auto_increment,
  name varchar(255) NOT NULL,
  directions_ID int(11) NOT NULL default '0',
  info text,
  price float default '0',
  active tinyint(1) NOT NULL default '1',
  options text,
  languages_NAME varchar(255) NOT NULL,
  metadata text,
  course_only tinyint(1) default '0',
  certificate text,
  from_timestamp varchar(255) default '',
  to_timestamp varchar(255) default '',
  shift tinyint(1) default '0',
  PRIMARY KEY  (id)
) DEFAULT CHARSET=utf8;

CREATE TABLE lesson_conditions (
  id int(11) NOT NULL auto_increment,
  lessons_ID int(11) NOT NULL,
  type varchar(255) NOT NULL,
  options text,
  relation varchar(255) NOT NULL default 'and',
  PRIMARY KEY  (id)
) DEFAULT CHARSET=utf8;

CREATE TABLE logs (
  id int(11) NOT NULL auto_increment,
  users_LOGIN varchar(255) NOT NULL,
  timestamp varchar(10) NOT NULL,
  action varchar(255) NOT NULL,
  comments varchar(255) NOT NULL default '0',
  session_ip varchar(255) NOT NULL default '0',
  lessons_ID int(11) default '0',
  PRIMARY KEY  (id)
) DEFAULT CHARSET=utf8;

CREATE TABLE modules (
  className varchar(255) NOT NULL,
  db_file varchar(255), 
  name varchar(255) NOT NULL,
  active tinyint(1) NOT NULL,
  title varchar(255) NOT NULL,
  author varchar(255) default NULL,
  version varchar(255) default NULL,
  description text,
  position varchar(255) NOT NULL,
  menu varchar(255) default NULL,
  mandatory varchar(255) default NULL,
  permissions varchar(255) NOT NULL default 'administrator',
  PRIMARY KEY  (className)
) DEFAULT CHARSET=utf8;

CREATE TABLE news (
  id int(11) NOT NULL auto_increment,
  title varchar(255) default NULL,
  data text,
  timestamp varchar(10) default NULL,
  lessons_ID int(11) default NULL,
  users_LOGIN varchar(255) NOT NULL,
  PRIMARY KEY  (id)
) DEFAULT CHARSET=utf8;

CREATE TABLE periods (
  id int(11) NOT NULL auto_increment,
  name varchar(255) NOT NULL,
  from_timestamp varchar(10) NOT NULL,
  to_timestamp varchar(10) NOT NULL,
  lessons_ID int(11) NOT NULL default '0',
  PRIMARY KEY  (id)
) DEFAULT CHARSET=utf8;

CREATE TABLE projects (
  id int(11) NOT NULL auto_increment,
  title varchar(255) default NULL,
  data text,
  deadline varchar(255) default NULL,
  creator_LOGIN varchar(255) NOT NULL,
  lessons_ID int(11) default NULL,
  auto_assign int(11) NOT NULL default '0',
  PRIMARY KEY  (id),
  KEY creator_LOGIN (creator_LOGIN),
  KEY deadline (deadline)
) DEFAULT CHARSET=utf8;

CREATE TABLE questions (
  id int(11) NOT NULL auto_increment,
  text text NOT NULL,
  type varchar(255) NOT NULL,
  content_ID varchar(255) NOT NULL,
  difficulty varchar(255) NOT NULL,
  options text,
  answer text,
  timestamp varchar(10) NOT NULL,
  explanation text,
  PRIMARY KEY  (id)
) DEFAULT CHARSET=utf8;

CREATE TABLE questions_to_surveys (
  id int(11) NOT NULL auto_increment,
  surveys_ID int(11) default NULL,
  type varchar(40) default NULL,
  question mediumtext,
  answers mediumtext NOT NULL,
  created int(11) default NULL,
  info mediumtext NOT NULL,
  father_ID int(11) default NULL,
  PRIMARY KEY  (id),
  KEY surveys_ID (surveys_ID)
) DEFAULT CHARSET=utf8;

CREATE TABLE rules (
  id int(11) NOT NULL auto_increment,
  users_LOGIN varchar(255) NOT NULL,
  content_ID int(11) NOT NULL default '0',
  rule_type varchar(255) NOT NULL,
  rule_content_ID int(11) default '0',
  rule_option float default '0',
  lessons_ID int(11) default '0',
  PRIMARY KEY  (id)
) DEFAULT CHARSET=utf8;

CREATE TABLE scorm_data (
  id int(11) NOT NULL auto_increment,
  content_ID int(11) NOT NULL default '0',
  users_LOGIN varchar(255) default NULL,
  timestamp int(11) default NULL,
  lesson_location text,
  maxtimeallowed varchar(255) default NULL,
  timelimitaction varchar(255) default NULL,
  masteryscore varchar(255) default NULL,
  datafromlms text,
  entry varchar(255) NOT NULL,
  total_time varchar(255) default NULL,
  comments varchar(255) default NULL,
  comments_from_lms text,
  lesson_status varchar(255) default NULL,
  score varchar(255) default NULL,
  scorm_exit varchar(255) default NULL,
  minscore varchar(255) default NULL,
  maxscore varchar(255) default NULL,
  suspend_data varchar(255) default NULL,
  PRIMARY KEY  (id)
) DEFAULT CHARSET=utf8;

CREATE TABLE search_keywords (
  keyword varchar(255) NOT NULL,
  foreign_ID int(11) NOT NULL default '0',
  table_name varchar(255) NOT NULL,
  position varchar(255) NOT NULL
) DEFAULT CHARSET=utf8;

CREATE TABLE surveys (
  id int(11) NOT NULL auto_increment,
  survey_code varchar(128) default NULL,
  survey_name varchar(256) default NULL,
  survey_info mediumtext,
  author mediumtext,
  lang varchar(16) default NULL,
  start_date int(11) default NULL,
  end_date int(11) default NULL,
  lessons_ID int(11) NOT NULL,
  status tinyint(1) default '0',
  start_text mediumtext,
  end_text mediumtext,
  PRIMARY KEY  (id),
  KEY survey_code (survey_code)
) DEFAULT CHARSET=utf8; 

CREATE TABLE survey_questions_done (
  id int(11) NOT NULL auto_increment,
  users_LOGIN varchar(20) NOT NULL,
  surveys_ID int(11) NOT NULL,
  question_ID int(11) NOT NULL,
  user_answers mediumtext NOT NULL,
  submited int(11) default NULL,
  PRIMARY KEY  (id)
) DEFAULT CHARSET=utf8;

CREATE TABLE tests (
  id int(11) NOT NULL auto_increment,
  active tinyint(1) NOT NULL default '0',
  content_ID int(11) NOT NULL default '0',
  duration varchar(10) NOT NULL,
  redoable int(11) NOT NULL default '0',
  onebyone tinyint(1) NOT NULL default '0',
  answers tinyint(1) NOT NULL default '1',
  description text,
  shuffle_questions tinyint(1) NOT NULL default '0',
  shuffle_answers tinyint(1) NOT NULL default '0',
  given_answers tinyint(1) NOT NULL default '1',  
  PRIMARY KEY  (id)
) DEFAULT CHARSET=utf8;

CREATE TABLE tests_to_questions (
  tests_ID int(11) NOT NULL default '0',
  questions_ID int(11) NOT NULL default '0',
  weight int(11) NOT NULL default '1',
  previous_question_ID int(11) NOT NULL default '0',
  primary key (tests_ID, questions_ID)
) DEFAULT CHARSET=utf8;

CREATE TABLE userpage (
  username varchar(255) NOT NULL,
  cv text,
  links tinyint(1) default NULL,
  users_login varchar(255) NOT NULL,
  link1 varchar(255) NOT NULL,
  link2 varchar(255) NOT NULL,
  link3 varchar(255) NOT NULL,
  link4 varchar(255) NOT NULL,
  active tinyint(1) NOT NULL,
  PRIMARY KEY  (username)
) DEFAULT CHARSET=utf8;

CREATE TABLE users (
  login varchar(255) NOT NULL,
  password varchar(255) NOT NULL,
  email varchar(255) NOT NULL,
  languages_NAME varchar(255) NOT NULL,
  name varchar(255) NOT NULL,
  surname varchar(255) NOT NULL,
  active tinyint(1) NOT NULL default '1',
  comments text,
  user_type varchar(255) NOT NULL default 'student',
  timestamp varchar(10) NOT NULL,
  avatar varchar(255) default NULL,
  pending tinyint(1) NOT NULL default '0',
  PRIMARY KEY  (login)
) DEFAULT CHARSET=utf8;

CREATE TABLE users_to_chatrooms (
  users_LOGIN varchar(255) NOT NULL,
  chatrooms_ID int(11) NOT NULL default '0',
  users_USER_TYPE varchar(255) NOT NULL,
  timestamp varchar(10) NOT NULL,
  primary key (users_LOGIN, chatrooms_ID)
) DEFAULT CHARSET=utf8;

CREATE TABLE users_to_courses (
  users_LOGIN varchar(255) NOT NULL,
  courses_ID int(11) NOT NULL default '0',
  active tinyint(1) NOT NULL default '0',
  from_timestamp varchar(255) default NULL,
  user_type varchar(255) default NULL,
  completed tinyint(1) NOT NULL default '0',
  score int(11) NOT NULL default '0',
  issued_certificate varchar(255) default NULL,
  comments text,
  to_timestamp varchar(255) default NULL,
  primary key (users_LOGIN, courses_ID)
) DEFAULT CHARSET=utf8;

CREATE TABLE lessons_to_courses (
  courses_ID int(11) NOT NULL,
  lessons_ID int(11) NOT NULL,
  previous_lessons_ID int(11),
  PRIMARY KEY  (lessons_ID, courses_ID)
) DEFAULT CHARSET=utf8;

CREATE TABLE users_to_done_surveys (
  surveys_ID int(11) default NULL,
  users_LOGIN varchar(20) default NULL,
  done tinyint(4) NOT NULL default '0',
  primary key (users_LOGIN, surveys_ID)
) DEFAULT CHARSET=utf8;

CREATE TABLE users_to_done_tests (
  tests_ID int(11) NOT NULL default '0',
  users_LOGIN varchar(255) NOT NULL,
  times int(11) NOT NULL default '0',
  questions_order text,
  answers_order text,
  primary key (users_LOGIN, tests_ID)
) DEFAULT CHARSET=utf8;

CREATE TABLE users_to_lessons (
  users_LOGIN varchar(255) NOT NULL,
  lessons_ID int(11) NOT NULL default '0',
  active tinyint(1) NOT NULL default '0',
  from_timestamp varchar(10) default NULL,
  user_type varchar(255) default NULL,
  positions text,
  done_content text,
  current_unit int(11) default 0,
  completed tinyint(1) NOT NULL default '0',
  score int(11) NOT NULL default '0',
  issued_certificate blob,
  comments text,
  to_timestamp varchar(255) default NULL,
  primary key (users_LOGIN, lessons_ID)
) DEFAULT CHARSET=utf8;

CREATE TABLE users_to_projects (
  users_LOGIN varchar(255) NOT NULL,
  projects_ID int(11) NOT NULL default '0',
  status tinyint(1) NOT NULL default '0',
  comments text,
  grade  varchar(50) DEFAULT '',
  filename varchar(255) default NULL,
  upload_timestamp varchar(255) NOT NULL default '',
  primary key (users_LOGIN, projects_ID)
) DEFAULT CHARSET=utf8;

CREATE TABLE users_to_surveys (
  surveys_ID int(11) NOT NULL,
  users_LOGIN varchar(20) NOT NULL,
  last_access int(11) default NULL,
  last_post int(11) default NULL,
  KEY surveys_ID (surveys_ID,users_LOGIN),
  primary key (users_LOGIN, surveys_ID)
) DEFAULT CHARSET=utf8;

CREATE TABLE user_profile (
  name varchar(255) NOT NULL,
  description varchar(255) NOT NULL,
  db_type varchar(255) NOT NULL,
  size varchar(255) NOT NULL,
  type varchar(255) default NULL,
  options text,
  default_value varchar(255) default NULL,
  active tinyint(1) NOT NULL default '1',
  visible tinyint(1) NOT NULL default '1',
  mandatory tinyint(1) NOT NULL default '1',
  languages_NAME varchar(255) NOT NULL,
  PRIMARY KEY  (name)
) DEFAULT CHARSET=utf8;

CREATE TABLE user_types (
  user_type varchar(255) NOT NULL,
  basic_user_type varchar(255) NOT NULL,
  characteristics text,
  active tinyint(1) NOT NULL default '1',
  PRIMARY KEY  (user_type)
) DEFAULT CHARSET=utf8;

CREATE TABLE tokens (
  token varchar(255) NOT NULL,
  status text  NOT NULL,
  users_LOGIN varchar(255),
  create_timestamp varchar(255) NOT NULL,
  expired tinyint(1) NOT NULL ,
  PRIMARY KEY  (token)
) DEFAULT CHARSET=utf8;

CREATE TABLE files (
  id int(11) NOT NULL auto_increment,
  path text NOT NULL,
  users_LOGIN varchar(255) NOT NULL,
  timestamp varchar(255) NOT NULL,
  description text,
  groups_ID int not null default 0,
  access int not null default 755,
  shared int(11) default 0,
  metadata text,
  PRIMARY KEY  (id)
) DEFAULT CHARSET=utf8;


CREATE TABLE module_hcd_skills (
  skill_ID int(11) NOT NULL auto_increment,
  description varchar(255) NOT NULL default '',
  categories_ID int(11) NOT NULL,
  PRIMARY KEY(skill_ID) 
) DEFAULT CHARSET=utf8;


CREATE TABLE module_hcd_skill_categories (
  id int(11) NOT NULL auto_increment,
  description varchar(255) NOT NULL default '',
  PRIMARY KEY(id) 
) DEFAULT CHARSET=utf8;

CREATE TABLE module_hcd_employee_has_skill (
  users_login varchar(255) NOT NULL,
  skill_ID int(11) NOT NULL,
  specification varchar(255) default '',
  author_login varchar(255) NOT NULL,
  PRIMARY KEY (users_login, skill_ID)
) DEFAULT CHARSET=utf8;


CREATE TABLE module_hcd_employee_has_job_description (
  users_login varchar(255) NOT NULL, 
  job_description_ID int(11) NOT NULL,
  PRIMARY KEY (users_login, job_description_ID) 
) DEFAULT CHARSET=utf8;

CREATE TABLE module_hcd_lesson_to_job_description (
  lessons_ID int(11) NOT NULL,
  job_description_ID int(11) NOT NULL,
  PRIMARY KEY (lessons_ID, job_description_ID) 
) DEFAULT CHARSET=utf8;

CREATE TABLE module_hcd_course_to_job_description (
  courses_ID int(11) NOT NULL,
  job_description_ID int(11) NOT NULL,
  PRIMARY KEY (courses_ID, job_description_ID) 
) DEFAULT CHARSET=utf8;

CREATE TABLE module_hcd_job_description_requires_skill (
  skill_ID int(11) NOT NULL,
  job_description_ID int(11) NOT NULL,
  PRIMARY KEY (skill_ID, job_description_ID) 
) DEFAULT CHARSET=utf8;

CREATE TABLE module_hcd_branch (
  branch_ID int(11) NOT NULL auto_increment,
  name varchar(255) NOT NULL default 'New Branch',
  address varchar(255),
  city varchar(255),
  country varchar(255),
  telephone varchar(255),
  email varchar(255),
  father_branch_ID int(11) default 0,
  PRIMARY KEY (branch_ID)
) DEFAULT CHARSET=utf8;


CREATE TABLE module_hcd_job_description (
  job_description_ID int(11) NOT NULL auto_increment,
  employees_needed int(11) default '1',
  description varchar(255) NOT NULL default 'New Job Description',
  job_role_description text, 
  branch_ID int(11) default '0',
  PRIMARY KEY (job_description_ID)
) DEFAULT CHARSET=utf8;

CREATE TABLE module_hcd_employee_works_at_branch (
  users_login varchar(255) NOT NULL,
  supervisor tinyint(1) default 0,
  assigned tinyint(1) default 0, 
  branch_ID int(11) NOT NULL,
  PRIMARY KEY users_login (users_login, supervisor, assigned, branch_ID) 
) DEFAULT CHARSET=utf8;


CREATE TABLE module_hcd_employees (
  users_login varchar(255) NOT NULL,
  wage int(11) default 0,
  hired_on varchar(10) default NULL,
  left_on varchar(10) default NULL,
  address varchar(255) default NULL,
  city varchar(255) default NULL,
  country varchar(255) default NULL,
  father varchar(255) default NULL,
  homephone varchar(255) default NULL,
  mobilephone varchar(255) default NULL,
  sex varchar(255) default NULL,
  birthday varchar(255) default NULL,
  birthplace varchar(255) default NULL,
  birthcountry varchar(255) default NULL,
  mother_tongue varchar(255) default NULL,
  nationality varchar(255) default NULL,
  company_internal_phone varchar(255) default NULL,
  office varchar(255) default NULL,
  doy varchar(255) default NULL,
  police_id_number varchar(255) default NULL,
  driving_licence tinyint(1) default 0,
  work_permission_data varchar(255) default NULL,
  national_service_completed tinyint(1) default 0,
  employement_type varchar(255) default NULL,
  bank varchar(255) default NULL,
  bank_account varchar(255) default NULL,
  marital_status tinyint(1) default 0,
  way_of_working tinyint(1) default 0,  
  afm varchar(255) default NULL,
  candidate tinyint(1) default 0,
  transport tinyint(1) default 0,
  PRIMARY KEY (users_login)
) DEFAULT CHARSET=utf8;

CREATE TABLE module_hcd_lesson_offers_skill (
  lesson_ID int(11) NOT NULL,
  skill_ID int(11) NOT NULL,
  specification varchar(255) default NULL, 
  PRIMARY KEY (lesson_ID, skill_ID)
) DEFAULT CHARSET=utf8;

CREATE TABLE module_hcd_course_offers_skill (
  courses_ID int(11) NOT NULL,
  skill_ID int(11) NOT NULL,
  specification varchar(255) default NULL, 
  PRIMARY KEY (courses_ID, skill_ID)
) DEFAULT CHARSET=utf8;

CREATE TABLE module_hcd_events (
  event_ID int(11) NOT NULL auto_increment,
  event_code int(11) NOT NULL DEFAULT 0,
  users_login varchar(255) NOT NULL,
  author varchar(255) NOT NULL default '',
  specification varchar(255) default '',
  timestamp varchar(10) NOT NULL,
  PRIMARY KEY (event_ID) 
) DEFAULT CHARSET=utf8;


CREATE TABLE groups (
  id int(11) NOT NULL auto_increment,
  name varchar(255) NOT NULL,
  description text,
  active int(1) NOT NULL default '1',
  PRIMARY KEY  (id)
) DEFAULT CHARSET=utf8;


CREATE TABLE users_to_groups (
  groups_ID int(11) NOT NULL,
  users_LOGIN varchar(255)  NOT NULL,
  PRIMARY KEY  (groups_ID,users_LOGIN)
) DEFAULT CHARSET=utf8;

CREATE TABLE users_online (
  users_LOGIN varchar(255) NOT NULL,
  timestamp varchar(10) NOT NULL,
  timestamp_now varchar(10) NOT NULL,
  session_ip varchar(255) NOT NULL,  
  PRIMARY KEY  (users_LOGIN)
) DEFAULT CHARSET=utf8;

CREATE TABLE paypal_configuration (
  paypalbusiness varchar(255) NOT NULL,
  mailstudents tinyint(1) NOT NULL default '0',
  mailprofessors tinyint(1) NOT NULL default '0',
  mailadmins tinyint(1) NOT NULL default '0'
) DEFAULT CHARSET=utf8;

CREATE TABLE paypal_data (
  id int(10) unsigned NOT NULL auto_increment,
  mc_gross varchar(20) default NULL,
  settle_amount varchar(15) NOT NULL,
  address_status varchar(10) default NULL,
  payer_id varchar(20) default NULL,
  tax varchar(20) default NULL,
  address_street varchar(150) default NULL,
  payment_date varchar(30) default NULL,
  payment_status varchar(10) default NULL,
  charset varchar(10) default NULL,
  address_zip varchar(20) default NULL,
  first_name varchar(30) default NULL,
  mc_fee varchar(20) default NULL,
  address_country_code varchar(3) default NULL,
  exchange_rate varchar(20) NOT NULL,
  address_name varchar(100) default NULL,
  notify_version varchar(5) default NULL,
  settle_currency varchar(5) NOT NULL,
  custom varchar(60) default NULL,
  payer_status varchar(10) default NULL,
  business varchar(60) default NULL,
  address_country varchar(30) default NULL,
  address_city varchar(30) default NULL,
  quantity varchar(6) default NULL,
  verify_sign varchar(10) default NULL,
  payer_email varchar(120) default NULL,
  txn_id varchar(255) default NULL,
  payment_type varchar(30) default NULL,
  last_name varchar(120) default NULL,
  address_state varchar(30) default NULL,
  receiver_email varchar(120) default NULL,
  payment_fee varchar(10) default NULL,
  receiver_id varchar(60) default NULL,
  txn_type varchar(10) default NULL,
  item_name text,
  mc_currency varchar(3) default NULL,
  item_number text,
  residence_country varchar(3) default NULL,
  test_ipn varchar(3) default NULL,
  payment_gross varchar(20) default NULL,
  shipping varchar(20) default NULL,
  transactionID varchar(50) NOT NULL,
  status varchar(15) NOT NULL,
  timestamp varchar(10) NOT NULL,
  timestamp_finish varchar(10) NOT NULL,
  user varchar(255) NOT NULL,
  PRIMARY KEY  (id)
)  DEFAULT CHARSET=utf8;