A tabela principal...:
CREATE TABLE Transfer (
idTransfer INTEGER IDENTITY,
serverID INTEGER,
serverURL VARCHAR,
transferSize INTEGER NOT NULL,
hits_last_hour INTEGER,
hits_total INTEGER,
register_time TIMESTAMP
);
A primeira tabela dependente da principal:
CREATE TABLE TransferBlock (
idTransfer INTEGER NOT NULL,
idTransferBlock INTEGER IDENTITY,
serverBlockId INTEGER,
pointer INTEGER NOT NULL,
datasize INTEGER NOT NULL,
dataoffset INTEGER NOT NULL,
hash INTEGER,
version INTEGER NOT NULL,
FOREIGN KEY (idTransfer) REFERENCES Transfer,
UNIQUE (
idTransfer,
idTransferBlock
)
);
E a terceira tabela, dependente das duas primeiras:
CREATE TABLE TransferBlockLink (O resultado deverá ser algo parecido com o do diagrama:
idTransfer INTEGER NOT NULL,
idTransferBlock INTEGER NOT NULL,
idLink INTEGER IDENTITY,
url VARCHAR(255) NOT NULL,
downloaded BOOLEAN NOT NULL,
damaged INTEGER NOT NULL,
FOREIGN KEY (idTransfer) REFERENCES Transfer,
FOREIGN KEY (idTransferBlock) REFERENCES TransferBlock,
UNIQUE (
idTransfer,
idTransferBlock,
idLink
)
);
Nenhum comentário:
Postar um comentário