SET client_encoding='utf-8';

CREATE TABLE czytelnik
(
    numer_karty            int   PRIMARY KEY,
    imie            varchar(32)   not null,
    nazwisko         varchar(32)   not null
);
CREATE TABLE autor
(
    numer_karty            int   PRIMARY KEY,
    imie            varchar(32)   not null,
    nazwisko         varchar(32)   not null
);
CREATE TABLE ksiazka
(
    numer_ksiazki            int           PRIMARY KEY,
    tytul             varchar(32)   not null,
    cena			int			not null,
    year1			int			not null,
    publisher        varchar(100)  not null,
    autor_name		varchar(100)   not null,	
    autor_surname		varchar(100)   not null
);
CREATE TABLE egzemplarz
(
	numer	int			PRIMARY KEY,
	numer_karty_fk1			int,
	CONSTRAINT numer_karty_fk	FOREIGN KEY(numer_karty_fk1) REFERENCES czytelnik(numer_karty),
	numer_ksiazki_fk1	int,
	CONSTRAINT numer_ksiazki_fk FOREIGN KEY(numer_ksiazki_fk1) REFERENCES ksiazka(numer_ksiazki),
	 data             date
);