Kod
CREATE TABLE t_gazeta (
nr int unsigned not null,
rok char(100) not null,
dzien date not null,
UNIQUE KEY nr (nr) );
CREATE TABLE t_mutacje (
id int unsigned not null auto_increment,
mutacja char(10) not null,
UNIQUE KEY id (id) );
CREATE TABLE t_dodatki (
id int unsigned not null auto_increment,
nazwa char(100) not null,
id_mutacja int,
UNIQUE KEY id (id),
FOREIGN KEY (id_mutacja) REFERENCES mutacje(id) ON UPDATE CASCADE ON DELETE RESTRICT );
CREATE TABLE t_dzialy (
id int unsigned not null,
nazwa char(50) not null,
UNIQUE KEY id (id) );
CREATE TABLE t_wiadomosci (
id int not null auto_increment,
nadtytul varchar(200),
tytul varchar(100) not null,
tresc text not null,
ramka text not null,
autor varchar(100),
zdjecie text,
priorytet tinyint default 0,
id_user_dodal int not null,
id_user_zmienil int not null,
data_dodal timestamp not null,
data_zmienil timestamp not null,
id_mutacja int not null,
id_dodatek int not null,
id_dzial int not null,
UNIQUE KEY id (id),
FOREIGN KEY (id_user_dodal, id_user_zmienil) REFERENCES users(id, id) ON UPDATE CASCADE ON DELETE RESTRICT,
FOREIGN KEY (id_mutacja) REFERENCES mutacje(id) ON UPDATE CASCADE ON DELETE RESTRICT,
FOREIGN KEY (id_dodatek) REFERENCES dodatki(id) ON UPDATE CASCADE ON DELETE RESTRICT,
FOREIGN KEY (id_dzial) REFERENCES dzialy(id) ON UPDATE CASCADE ON DELETE RESTRICT );
CREATE TABLE t_users (
id int not null auto_increment,
nazwa char(50),
haslo char(100),
UNIQUE KEY id (id) );
nr int unsigned not null,
rok char(100) not null,
dzien date not null,
UNIQUE KEY nr (nr) );
CREATE TABLE t_mutacje (
id int unsigned not null auto_increment,
mutacja char(10) not null,
UNIQUE KEY id (id) );
CREATE TABLE t_dodatki (
id int unsigned not null auto_increment,
nazwa char(100) not null,
id_mutacja int,
UNIQUE KEY id (id),
FOREIGN KEY (id_mutacja) REFERENCES mutacje(id) ON UPDATE CASCADE ON DELETE RESTRICT );
CREATE TABLE t_dzialy (
id int unsigned not null,
nazwa char(50) not null,
UNIQUE KEY id (id) );
CREATE TABLE t_wiadomosci (
id int not null auto_increment,
nadtytul varchar(200),
tytul varchar(100) not null,
tresc text not null,
ramka text not null,
autor varchar(100),
zdjecie text,
priorytet tinyint default 0,
id_user_dodal int not null,
id_user_zmienil int not null,
data_dodal timestamp not null,
data_zmienil timestamp not null,
id_mutacja int not null,
id_dodatek int not null,
id_dzial int not null,
UNIQUE KEY id (id),
FOREIGN KEY (id_user_dodal, id_user_zmienil) REFERENCES users(id, id) ON UPDATE CASCADE ON DELETE RESTRICT,
FOREIGN KEY (id_mutacja) REFERENCES mutacje(id) ON UPDATE CASCADE ON DELETE RESTRICT,
FOREIGN KEY (id_dodatek) REFERENCES dodatki(id) ON UPDATE CASCADE ON DELETE RESTRICT,
FOREIGN KEY (id_dzial) REFERENCES dzialy(id) ON UPDATE CASCADE ON DELETE RESTRICT );
CREATE TABLE t_users (
id int not null auto_increment,
nazwa char(50),
haslo char(100),
UNIQUE KEY id (id) );
problem jest taki, ze codziennie jest nowe wydanie gazety okreslone nr wydania rokiem i dniem wydania, gazeta jest wydawana w 4 regionach-mutacjach (ew. wiecej) kazda mutacja ma swoj dzial - wiadomosci/sport/opinie/cośtam, sa jeszcze dodatki do gazety (motoryzacja, praca) no i sa wiadomosci ktore maja sie pojawiac albo w okreslonym dziale i mutacji, lub w dodatku i mutacji.
przypuszczam, ze przydaloby sie jakies indexowanie, jako ze codziennie bedzie przybywalo ok. 20 wiadomosci.
prosze o opinie - co zrobic aby baza się sprawdziła i była funkcjonalna.