We need to
create database tables for database persistence. Create database tables CATALOG
, EDITION
, SECTION
, and ARTICLE
with the following SQL script; the script can be run from the SQL command line:
CREATE TABLE CATALOG (id INTEGER PRIMARY KEY NOT NULL, journal VARCHAR(100)); CREATE TABLE EDITION (id INTEGER PRIMARY KEY NOT NULL, edition VARCHAR(100)); CREATE TABLE SECTION (id VARCHAR(100) PRIMARY KEY NOT NULL, sectionName VARCHAR(100)); CREATE TABLE ARTICLE(id INTEGER PRIMARY KEY NOT NULL, title VARCHAR(100));
As Oracle database does not support the autoincrement of primary keys, we need to create sequences for autoincrementing, one for each table. Create sequences CATALOG_SEQ
, EDITION_SEQ
, SECTION_SEQ
, and ARTICLE_SEQ
with the following SQL script.
CREATE SEQUENCE CATALOG_SEQ MINVALUE 1 START WITH 1 INCREMENT BY 1 NOCACHE; CREATE SEQUENCE EDITION_SEQ MINVALUE 1 START WITH 1 INCREMENT BY 1 NOCACHE; CREATE SEQUENCE SECTION_SEQ MINVALUE 1 START WITH 1 INCREMENT BY 1 NOCACHE; CREATE SEQUENCE ARTICLE_SEQ MINVALUE 1 START WITH 1 INCREMENT BY 1 NOCACHE;
We also need to create join tables between tables. Create join tables using the following SQL script:
CREATE TABLE CATALOGEDITIONS(catalogId INTEGER, editionId INTEGER); CREATE TABLE EditionCatalog(editionId INTEGER, catalogId INTEGER); CREATE TABLE EditionSections (editionId INTEGER, sectionId INTEGER); CREATE TABLE SectionEdition (sectionId INTEGER, editionId INTEGER); CREATE TABLE SectionArticles(sectionId INTEGER, articleId INTEGER); CREATE TABLE ArticleSection(articleId INTEGER, sectionId INTEGER);