Database Design Example Phase 3: Implementation

You are viewing an old version of this article. View the current version here.

This article is currently incomplete.

This article follows on from Database Design Example Phase 2: Design.

With the design complete, it's time to install MariaDB and run the CREATE statements, as follows:

CREATE DATABASE poets_circle;

CREATE TABLE poet (
  poet_code INT NOT NULL, 
  first_name VARCHAR(30),
  surname VARCHAR(40), 
  address VARCHAR(100), 
  postcode VARCHAR(20),
  email VARCHAR(254), 
  PRIMARY KEY(poet_code)
);

CREATE TABLE poem(
  poem_code INT NOT NULL, 
  title VARCHAR(50),
  contents TEXT, 
  poet_code INT NOT NULL, 
  PRIMARY KEY(poem_code),
  INDEX(poet_code), 
  CONSTRAINT fk_poet_code
    FOREIGN KEY(poet_code) REFERENCES poet(poet_code) 
);

Comments

Comments loading...
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.