-
Notifications
You must be signed in to change notification settings - Fork 0
/
DDL.doc.comp.sql
36 lines (31 loc) · 1.64 KB
/
DDL.doc.comp.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
CREATE TABLE DOCUMENT_TYPE (
ID NUMBER GENERATED ALWAYS as IDENTITY ( START WITH 1 INCREMENT BY 1 ) PRIMARY KEY,
NAME VARCHAR2(32) NOT NULL UNIQUE,
DETAILS VARCHAR2(1024)
);
-- @ManyToOne Doc & Type Any Document can be of 1 type only
CREATE TABLE DOCUMENT (
ID NUMBER GENERATED ALWAYS as IDENTITY ( START WITH 1 INCREMENT BY 1 ) PRIMARY KEY,
DOCUMENT_TYPE NUMBER CONSTRAINT document_type REFERENCES DOCUMENT_TYPE( ID ) ON DELETE CASCADE,
NAME VARCHAR2(32) NOT NULL UNIQUE,
DETAILS VARCHAR2(1024)
);
CREATE TABLE SIGNATURE (
ID NUMBER GENERATED ALWAYS as IDENTITY ( START WITH 1 INCREMENT BY 1 ) PRIMARY KEY,
NAME VARCHAR2(32) NOT NULL UNIQUE,
DETAILS VARCHAR2(1024)
);
-- @OneToMany Company & Contracts Bidirectional relationship
CREATE TABLE COMPANY (
ID NUMBER GENERATED ALWAYS as IDENTITY ( START WITH 1 INCREMENT BY 1 ) PRIMARY KEY,
NAME VARCHAR2(32) NOT NULL UNIQUE,
DETAILS VARCHAR2(1024)
);
-- @ManyToMany Contract & Documents Any Contract may contains multiple documents
-- @ManyToMany Contract & Signatures Any Contract may be signed by multiple signatures
CREATE TABLE CONTRACT (
ID NUMBER GENERATED ALWAYS as IDENTITY ( START WITH 1 INCREMENT BY 1 ) PRIMARY KEY,
COMPANY NUMBER CONSTRAINT contract_company REFERENCES COMPANY( ID ) ON DELETE CASCADE,
NAME VARCHAR2(32) NOT NULL UNIQUE,
DETAILS VARCHAR2(1024)
);