SET SQL DIALECT 3;

/* CREATE DATABASE 'F:\Firebird_1_5\databases\EURO_CURRENCYEXCHANGE.FDB' PAGE_SIZE 4096

 DEFAULT CHARACTER SET UNICODE_FSS */

/* Table: Currencies, Owner: SYSDBA */

CREATE TABLE "Currencies" 
(
  "NumCode"	 INTEGER NOT NULL,
  "CharCode"	 CHAR(11) CHARACTER SET UNICODE_FSS NOT NULL,
  "CurrName"	 CHAR(30) CHARACTER SET UNICODE_FSS NOT NULL,
CONSTRAINT "PK_Currencies" PRIMARY KEY ("NumCode")
);

/* Table: Valute, Owner: SYSDBA */

CREATE TABLE "Valute" 
(
  "RefNumCode"	 INTEGER NOT NULL,
  "NumCode"	 INTEGER NOT NULL,
  "ExDate"	 DATE NOT NULL,
  "ExNominal"	 INTEGER NOT NULL,
  "ExValue"	 NUMERIC(18,4) NOT NULL,
CONSTRAINT "PK_Valute" PRIMARY KEY ("RefNumCode", "NumCode", "ExDate")
);

/*  Index definitions for all user tables */

CREATE UNIQUE INDEX "IDX_CharCode" ON "Currencies"("CharCode");
CREATE UNIQUE INDEX "IDX_CurrName" ON "Currencies"("CurrName");
CREATE INDEX "IDX_ExDate" ON "Valute"("ExDate");
CREATE INDEX "IDX_NumCode" ON "Valute"("NumCode");
ALTER TABLE "Valute" ADD CONSTRAINT "FK_NumCode" FOREIGN KEY ("NumCode") REFERENCES "Currencies" ("NumCode") ON UPDATE CASCADE ON DELETE NO ACTION;
ALTER TABLE "Valute" ADD CONSTRAINT "FK_RefNumCode" FOREIGN KEY ("RefNumCode") REFERENCES "Currencies" ("NumCode") ON UPDATE CASCADE ON DELETE NO ACTION;


/* Grant Roles for this database */


/* Grant permissions for this database */
