here is my whole database
CREATE DATABASE announcements_system;
USE announcements_system;
CREATE TABLE users (
userid int not null auto_increment,
username varchar(30) not null,
password varchar(40) not null,
fname varchar(30) not null,
lname varchar(30) not null,
email varchar(30) not null,
phone_number varchar(20) not null,
user_level tinyint(2) not null,
ip varchar(20) not null,
PRIMARY KEY (userid) );
CREATE TABLE categories (
categoryid int not null auto_increment,
category VARCHAR(70) not null,
description VARCHAR(220) not null,
primary key (categoryid)) ;
CREATE TABLE post (
postid int NOT NULL AUTO_InCREMENT,
userid int not null,
typeid tinyint not NULL,
languageid tinyint not NULL,
relevant_link VARCHAR(150) not null,
image VARCHAR(20) not null,
date_posted DATE not null,
expire_date DATE not null,
mid_date bigint not null,
last_update date not null,
primary key (postid) );
CREATE TABLE announcement (
postid int not NULL,
title VARCHAR(250) not null,
categoryid int not null,
post text not null,
primary key (postid) );
CREATE TABLE conference (
postid int not NULL,
title VARCHAR(250) not null,
date date not null,
organization text not null,
post text not null,
place VARCHAR(70) not null,
date_description VARCHAR(80) not null,
primary key (postid) );
CREATE TABLE exhibition (
postid int not NULL,
title VARCHAR(250) not null,
subtitle VARCHAR(250) not null,
date date not null,
time VARCHAR(30) not null,
text text not null,
place VARCHAR(70) not null,
entrance VARCHAR(50) not null,
contact VARCHAR(100) not null,
organization VARCHAR(100),
date_description VARCHAR(80) not null,
primary key (postid) );
CREATE TABLE seminar (
postid int not NULL,
department VARCHAR(50) not null,
domain VARCHAR(70) not null,
spokesman VARCHAR(70) not null,
title VARCHAR(250) not null,
subject VARCHAR(250) not null,
overview text not null,
date date not null,
time VARCHAR(30) not null,
room VARCHAR(70) not null,
organization text not null,
school VARCHAR(50) not null,
affiliation VARCHAR(100) not null,
primary key (postid) );
CREATE TABLE types (
typeid tinyint not NULL AUTO_INCREMENT,
type VARCHAR(30),
primary key(typeid));
CREATE TABLE languages (
languageid tinyint not NULL AUTO_INCREMENT,
language VARCHAR(20),
primary key(languageid));
CREATE TABLE user_type (
userid int not null,
typeid int not NULL,
PRIMARY KEY (userid, typeid));
CREATE TABLE user_category (
userid int not null,
categoryid int not null,
PRIMARY KEY (userid, categoryid));
CREATE TABLE school (
schoolid smallint not null AUTO_INCREMENT,
school VARCHAR(50) not null,
department VARCHAR(50) not null,
PRIMARY KEY(schoolid));
The table post containts mostly the information
Obviously, i have set limits by WHERE condition. But i need an optimization!