USERNAMES: Tabulka uzivatelskych jmen

CREATE TABLE usernames (
*       uid             int PRIMARY KEY,	
*       username        varchar(8) UNIQUE NOT NULL,
*       password        varchar(15),
 	firstname       varchar(20),
        lastname        varchar(20),
	fullname	varchar(40),
	kos		int,		 
        timestamp       datetime,
        source          int check (source between 0 and 1) default 0,
        author          int,
	script		varchar(40),
        comment         varchar(80)

);
- uid je nase vlastni, generuje se pomoci sequence next_uid: 
	nextval('next_uid')
- kos je u ucitelu a studentu identifikator osoby v KOSu, u ostatnich NULL


- timestamp se doplni prostrednictvim triggeru
- source: 0 pro automaticky vkladane zaznamy (KOS), 1 pro rucni praci
- author - to zatim nejak nepouzivam
- script - nazev programu/scriptu, ktery zaznam vytvoril
- Tyto atributy a jejich vyznam jsou shodne ve vsech tabulkach

- comment - komentar pro rucne zalozeneho uzivatele
-------------------------------------------------------------------

GROUPNAMES: Nazvy a GID jednotlivych skupin

CREATE TABLE groupnames (
*       gid             int PRIMARY KEY,
        groupname       varchar(10) UNIQUE NOT NULL,
        timestamp       datetime,			-- doplni trigger
        source          int check (source between 0 and 1) default 0,
        author          int,
	script		varchar(40),
        comment         varchar(80)
);
-------------------------------------------------------------------

GROUPS: Clenstvi ve skupinach

- dvojice uid a gid vlastne rikaji, jaci uzivatele jsou v jednotlivych
- skupinach

CREATE TABLE groups (
*       gid             int REFERENCES groupnames(gid) 
				ON DELETE CASCADE on update cascade,
*       uid             int REFERENCES usernames(uid) 
				ON DELETE CASCADE on update cascade,
        timestamp       datetime,			-- doplni trigger
        source          int check (source between 0 and 1) default 0,
        author          int,
	script		varchar(40),
        UNIQUE(gid, uid)
);
-------------------------------------------------------------------

PATHS: adresare, ke kterym lze pridelovat pristupova prava

CREATE TABLE paths (
*       pid             int PRIMARY KEY,
*       path            varchar(256) UNIQUE NOT NULL,
        timestamp       datetime,			-- doplni trigger
        source          int check (source between 0 and 1) default 0,
        author          int,
	script		varchar(40)
);

- pid  Path ID
- path je cesta v souborovem systemu ('/data/hardweb/subdir'), nikoliv
  v URL
-------------------------------------------------------------------

USERPERMS: Pristupova prava jednotlivych uzivatelu

CREATE TABLE userperms (
*       pid             int REFERENCES paths(pid) 
				ON DELETE CASCADE on update cascade,
*       uid             int REFERENCES usernames(uid) 
				ON DELETE CASCADE on update cascade,
*       permission      int,
        timestamp       datetime,			-- doplni trigger
        source          int check (source between 0 and 1) default 0,
        author          int,
	script		varchar(40),
        UNIQUE(pid, uid)
);

- pid   identifikace adresare
- uid   identifikace uzivatele
- permission - povolene http metody (binarni pole)
               GET/HEAD je 1, POST 4
	takze: 0 zadny pristup, read only 5, vsechno 65535
-------------------------------------------------------------------

GROUPPERMS: Pristupova prava pro skupiny uzivatelu

CREATE TABLE groupperms (
*       pid             int REFERENCES paths(pid) 
				ON DELETE CASCADE on update cascade,
*       gid             int REFERENCES groupnames(gid) 
				ON DELETE CASCADE on update cascade,
*       permission      int,
        timestamp       datetime,                       -- doplni trigger
        source          int check (source between 0 and 1) default 0,
        author          int,
        script          varchar(40)
----------------------------------------------------------------------
