Index: DB/kreiranje.sql
===================================================================
--- DB/kreiranje.sql	(revision 6da3d1219724e6cc630cbd93d4db63fa7728dacc)
+++ DB/kreiranje.sql	(revision 6da3d1219724e6cc630cbd93d4db63fa7728dacc)
@@ -0,0 +1,196 @@
+--drop schema if exists project cascade;
+create schema project;
+
+--drop table if exists PERSON;
+--drop table if exists LIBRARY_DB;
+--drop table if exists EMPLOYEE;
+--drop table if exists SCHOOL_TYPE;
+--drop table if exists MEMBERSHIP_TYPE;
+--drop table if exists MEMBER_LIBRARY;
+--drop table if exists PRICE;
+--drop table if exists ROOM;
+--drop table if exists BOOK;
+--drop table if exists GENRE;
+--drop table if exists REVIEW;
+--drop table if exists WRITER;
+--drop table if exists ONLINE_DOWNLOAD;
+--drop table if exists RESERVATION_BOOK;
+--drop table if exists RESERVATION_PLACE;
+--drop table if exists MEMBERSHIP_OF_SCHOOLTYPE;
+--drop table if exists WRITER_OF_BOOK;
+
+
+create table PERSON (
+ id_person serial primary key,
+ namee varchar(9) not null,
+ surname varchar (12) not null,
+ address varchar (25) not null,
+ town varchar(10) not null, 
+ phone_num varchar(15) not null,
+ birth date,
+ email varchar(45) not null,
+ pass varchar (16) not null
+);
+
+create table LIBRARY_DB(
+ id_library serial  primary key,
+ names varchar (30) not null,
+ city varchar(13) not null 
+);
+
+create table EMPLOYEE(
+ id_person integer primary key,
+ id_library integer not null,
+ constraint fk_idperson_employee foreign key(id_person) references PERSON  (id_person),
+ constraint fk_library_employee foreign key(id_library) references LIBRARY_DB (id_library),
+ positionn varchar(14) not null
+);
+
+  
+create table SCHOOL_TYPE(
+ id_school serial  primary key,
+ school_type_name varchar (40) not null 
+);
+
+create table MEMBERSHIP_TYPE (
+ id_membership serial  primary key,
+ mem_type_name varchar (35) not null
+);
+
+
+create table MEMBER_LIBRARY(
+ id_person integer primary key,
+ id_school integer not null,
+ id_membership integer not null,
+ id_library integer not null,
+ isPayedMemebership boolean not null,
+ isPayedBook boolean not null,
+ constraint fk_person_member foreign key (id_person) references PERSON (id_person),
+ constraint fk_school_member foreign key (id_school) references SCHOOL_TYPE (id_school),
+ constraint fk_membership_member foreign key (id_membership) references MEMBERSHIP_TYPE (id_membership),
+ constraint fk_libraryy_member foreign key (id_library) references LIBRARY_DB (id_library)
+);
+
+
+create table PRICELIST (
+ id_price integer  primary key,
+ id_membership  integer not null,
+ price integer not null,
+ constraint fk_membership_price foreign key (id_membership) references MEMBERSHIP_TYPE (id_membership)
+);
+
+
+create table ROOM (
+ id_room integer primary  key,
+ places integer not null,
+ free_places integer not null,
+ id_library integer not null,
+ constraint fk_library_room foreign key (id_library) references LIBRARY_DB (id_library)
+);
+
+
+create table GENRE(
+ id_genre serial primary key,
+ namee varchar(60) not null
+);
+
+
+create table BOOK(
+ id_book serial  primary key,
+ id_library  integer not  null,
+ id_genre integer  not null,
+ namee varchar(120) not null, 
+ book_num integer not null, 
+ if_free boolean not null,
+ book_price integer  not null,
+ book_price_late integer not null, 
+ constraint fk_library_book foreign key (id_library) references  LIBRARY_DB (id_library),
+ constraint fk_genre_book foreign key (id_genre) references  GENRE (id_genre)
+);
+
+create table REVIEW (
+ id_review integer primary key,
+ rent_num integer not null,
+ rate integer not null,
+ id_book integer not null,
+ constraint fk_book_review foreign key (id_book) references BOOK (id_book)
+);
+
+
+create table WRITER (
+ id_writer serial primary key, 
+ namee varchar(70) not null,
+ book_num integer not null
+);
+
+
+create table ONLINE_DOWNLOAD (
+ id_onlineDown integer primary  key,
+ id_book integer not null,
+ id_member integer not null,
+ downloaded integer not null,
+ constraint fk_book_download foreign key (id_book) references  BOOK (id_book),
+ constraint fk_personmember_down foreign key (id_member) references  MEMBER_LIBRARY (id_person)
+);
+
+
+create table RESERVATION_BOOK(
+ id_resBook serial  primary key,
+ id_book integer  not null,
+ id_member integer not null,
+ take_date date not null,
+ return_date date not null,
+ isReservedBook boolean not null,
+ constraint fk_book_reservation foreign key (id_book) references BOOK (id_book),
+ constraint fk_person_member_reservation  foreign  key (id_member) references MEMBER_LIBRARY (id_person)
+);
+
+  
+create table RESERVATION_PLACE(
+ id_resRoom serial primary key,
+ id_member integer not null,
+ id_room integer not null,
+ coming_date date not null,
+ comingTime time not null,
+ leavingTime time not null,
+ constraint fk_person_member_place foreign key (id_member) references MEMBER_LIBRARY (id_person),
+ constraint fk_room_place foreign key (id_room) references  ROOM (id_room)
+);
+
+
+create table MEMBERSHIP_OF_SCHOOLTYPE(
+ id_membership integer  primary key,
+ id_school  integer not null,
+ constraint fk_membership_of foreign key (id_membership) references MEMBERSHIP_TYPE  (id_membership),
+ constraint fk_school_of foreign key (id_school) references SCHOOL_TYPE  (id_school)
+);
+
+  
+create table WRITER_OF_BOOK(
+ id_book integer primary key,
+ id_writer integer not null,
+ constraint fk_book_who_write foreign key (id_book) references BOOK (id_book),
+ constraint fk_write_who foreign key (id_writer) references WRITER (id_writer)
+);
+
+
+--DEL ZA BRISHENJE NA TABELI--
+
+--delete from PERSON;
+--delete from LIBRARY_DB;
+--delete from EMPLOYEE;
+--delete from SCHOOL_TYPE;
+--delete from MEMBERSHIP_TYPE;
+--delete from MEMBER_LIBRARY;
+--delete from PRICE;
+--delete from ROOM;
+--delete from BOOK;
+--delete from GENRE;
+--delete from REVIEW;
+--delete from WRITER;
+--delete from ONLINE_DOWNLOAD;
+--delete from RESERVATION_BOOK;
+--delete from RESERVATION_PLACE;
+--delete from MEMBERSHIP_OF_SCHOOLTYPE;
+--delete from WRITER_OF_BOOK;
+
Index: DB/polnenje.sql
===================================================================
--- DB/polnenje.sql	(revision 6da3d1219724e6cc630cbd93d4db63fa7728dacc)
+++ DB/polnenje.sql	(revision 6da3d1219724e6cc630cbd93d4db63fa7728dacc)
@@ -0,0 +1,55 @@
+insert into PERSON(id_person, namee, surname, address, town, phone_num, birth, email, pass)
+  values (1,'Marija','Markovska','ul.Partizanski Odredi','Skopje','070555666', '2001-10-27', 'marija@gmail.com', 'marija5932'),
+         (2, 'Aleks','Aleksikj','ul.Oktomvriska Revolucija','Kumanovo','075855744', '2001-12-31', 'aleksa@hotmail.com', 'aleks8908');
+
+insert into LIBRARY_DB(id_library, names, city) 
+  values (201,'Sv.Braka Miladinovci', 'Skopje'),
+       (202, 'Tane Georgievski','Kumanovo');
+
+insert into EMPLOYEE(id_person,id_library,positionn)
+   values (1,201,'bibliotekar');
+
+insert into SCHOOL_TYPE (id_school, school_type_name)
+   values (21,'Osnovno uciliste');
+
+insert into MEMBERSHIP_TYPE (id_membership, mem_type_name)
+   values(010, 'ucenik-clenstvo');
+
+insert into MEMBER_LIBRARY (id_person, id_school, id_membership, id_library, isPayedMemebership, isPayedBook)
+   values (1, 21, 010, 202, True, True);
+
+insert into PRICELIST  (id_price , id_membership, price)
+   values (41,010,200);
+
+insert into ROOM (id_room, places, free_places, id_library)
+   values (2,60,10,202);
+
+insert into GENRE (id_genre, namee)
+   values (17,'novel');
+
+insert into BOOK (id_book, id_library, namee, book_num, if_free, book_price, book_price_late, id_genre)
+   values (1,201,'Game of Thrones',4,True, 30, 45,17);
+
+
+insert into REVIEW (id_review, rent_num, rate, id_book)
+   values (7,15,8,1);
+
+insert into WRITER (id_writer, namee, book_num)
+   values (5,'George R. R. Martin',60);
+
+insert into ONLINE_DOWNLOAD (id_onlineDown, id_book, id_member, downloaded)
+   values(21,1,1,1);
+
+insert into RESERVATION_BOOK (id_resBook, id_book, id_member, take_date, return_date, isReservedBook)
+   values (07, 1, 1, '2022-02-5', '2021-02-18', True);
+
+
+insert into RESERVATION_PLACE (id_resRoom, id_member, id_room, coming_date, comingTime, leavingTime)
+   values(205, 1, 2, '2022-02-15', '13:00', '10:00');
+
+insert into MEMBERSHIP_OF_SCHOOLTYPE (id_membership, id_school)
+   values (010,21);
+
+
+insert into WRITER_OF_BOOK (id_book,id_writer)
+   values(1,5);
