7 | | {{{#!box type="info" |
8 | | Тука треба да се стават SQL DDL изрази со кои се креира структурата на релациската шема во PostgreSQL. Може да се извадат од последната структура на базата со DBeaver или со друга алатка. |
9 | | }}} |
| 3 | CREATE TABLE market_assesment.individuals ( |
| 4 | individual_id int4 NOT NULL DEFAULT nextval('market_assesment.individuals_individual_id_seq'::regclass), |
| 5 | name_surname varchar(255) NOT NULL, |
| 6 | experience_level varchar(255) NULL, |
| 7 | contact varchar(255) NOT NULL, |
| 8 | profession varchar(255) NULL, |
| 9 | education varchar(255) NULL, |
| 10 | company_training varchar(255) NULL, |
| 11 | training_interest varchar(255) NULL, |
| 12 | registration_id int4 NULL, |
| 13 | CONSTRAINT individuals_experience_level_check CHECK((experience_level)::text = ANY ((ARRAY['Студент'::character varying, 'Професионалец'::character varying])::text[])), |
| 14 | CONSTRAINT individuals_pkey PRIMARY KEY (individual_id), |
| 15 | CONSTRAINT individuals_registration_id_fk FOREIGN KEY (registration_id) REFERENCES market_assesment.registrations(registration_id) |
| 16 | ) |
| 17 | WITH ( |
| 18 | OIDS=FALSE |
| 19 | ); |
11 | | {{{ |
12 | | create schema ... |
| 21 | CREATE TABLE market_assesment.organizations ( |
| 22 | organization_id int4 NOT NULL DEFAULT nextval('market_assesment.organizations_organization_id_seq'::regclass), |
| 23 | org_name varchar(255) NOT NULL, |
| 24 | org_type varchar(255) NOT NULL, |
| 25 | register_number varchar(255) NOT NULL, |
| 26 | employee_size int4 NULL, |
| 27 | contact varchar(255) NOT NULL, |
| 28 | database_in_use varchar(255) NULL, |
| 29 | registration_id int4 NULL, |
| 30 | CONSTRAINT organizations_pkey PRIMARY KEY (organization_id), |
| 31 | CONSTRAINT organizations_registration_id_fk FOREIGN KEY (registration_id) REFERENCES market_assesment.registrations(registration_id) |
| 32 | ) |
| 33 | WITH ( |
| 34 | OIDS=FALSE |
| 35 | ); |
14 | | create table ... |
15 | | }}} |
| 37 | CREATE TABLE market_assesment.registrations ( |
| 38 | registration_id int4 NOT NULL DEFAULT nextval('market_assesment.registrations_registration_id_seq'::regclass), |
| 39 | username varchar(80) NOT NULL, |
| 40 | password varchar(255) NOT NULL, |
| 41 | register_date timestamp NULL DEFAULT now(), |
| 42 | user_type varchar(13) NULL, |
| 43 | CONSTRAINT registrations_pkey PRIMARY KEY (registration_id), |
| 44 | CONSTRAINT registrations_user_type_check CHECK((user_type)::text = ANY ((ARRAY['Организација'::character varying, 'Поединец'::character varying])::text[])), |
| 45 | CONSTRAINT registrations_username_key UNIQUE (username) |
| 46 | ) |
| 47 | WITH ( |
| 48 | OIDS=FALSE |
| 49 | ); |
| 50 | |
| 51 | CREATE TABLE market_assesment.services ( |
| 52 | service_id int4 NOT NULL DEFAULT nextval('market_assesment.services_service_id_seq'::regclass), |
| 53 | service_direction varchar(4) NOT NULL, |
| 54 | service_name varchar(255) NULL, |
| 55 | service_type varchar(255) NOT NULL, |
| 56 | database_name varchar(255) NULL, |
| 57 | database_type varchar(255) NULL, |
| 58 | dbms_version varchar(255) NULL, |
| 59 | service_description text NULL, |
| 60 | salary varchar(255) NULL, |
| 61 | status varchar(8) NOT NULL, |
| 62 | start_date date NOT NULL, |
| 63 | end_date date NULL, |
| 64 | price varchar(255) NULL, |
| 65 | organization_id int4 NULL, |
| 66 | individual_id int4 NULL, |
| 67 | CONSTRAINT services_pkey PRIMARY KEY (service_id), |
| 68 | CONSTRAINT services_status_check CHECK((status)::text = ANY ((ARRAY['Активна'::character varying, 'Неактивна'::character varying])::text[])), |
| 69 | CONSTRAINT services_individual_fkey FOREIGN KEY (individual_id) REFERENCES market_assesment.individuals(individual_id), |
| 70 | CONSTRAINT services_organization_fkey FOREIGN KEY (organization_id) REFERENCES market_assesment.organizations(organization_id) |
| 71 | ) |
| 72 | WITH ( |
| 73 | OIDS=FALSE |
| 74 | ); |
| 75 | |
| 76 | CREATE TABLE market_assesment.users ( |
| 77 | user_id int4 NOT NULL DEFAULT nextval('market_assesment.users_user_id_seq'::regclass), |
| 78 | last_login timestamp NULL DEFAULT now(), |
| 79 | CONSTRAINT users_pkey PRIMARY KEY (user_id) |
| 80 | ) |
| 81 | WITH ( |
| 82 | OIDS=FALSE |
| 83 | ); |