|
Spring Framework example source code file (initDB.txt)
The Spring Framework initDB.txt source codeUSE petclinic; CREATE TABLE vets ( id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, first_name VARCHAR(30), last_name VARCHAR(30), INDEX(last_name) ) engine=InnoDB; CREATE TABLE specialties ( id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(80), INDEX(name) ) engine=InnoDB; CREATE TABLE vet_specialties ( vet_id INT(4) UNSIGNED NOT NULL, specialty_id INT(4) UNSIGNED NOT NULL ) engine=InnoDB; ALTER TABLE vet_specialties ADD CONSTRAINT fk_vet_specialties_vets FOREIGN KEY (vet_id) REFERENCES vets(id); ALTER TABLE vet_specialties ADD CONSTRAINT fk_vet_specialties_specialties FOREIGN KEY (specialty_id) REFERENCES specialties(id); CREATE TABLE types ( id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(80), INDEX(name) ) engine=InnoDB; CREATE TABLE owners ( id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, first_name VARCHAR(30), last_name VARCHAR(30), address VARCHAR(255), city VARCHAR(80), telephone VARCHAR(20), INDEX(last_name) ) engine=InnoDB; CREATE TABLE pets ( id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(30), birth_date DATE, type_id INT(4) UNSIGNED NOT NULL, owner_id INT(4) UNSIGNED NOT NULL, INDEX(name) ) engine=InnoDB; ALTER TABLE pets ADD CONSTRAINT fk_pets_owners FOREIGN KEY (owner_id) REFERENCES owners(id); ALTER TABLE pets ADD CONSTRAINT fk_pets_types FOREIGN KEY (type_id) REFERENCES types(id); CREATE INDEX pets_name ON pets(name); CREATE TABLE visits ( id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, pet_id INT(4) UNSIGNED NOT NULL, visit_date DATE, description VARCHAR(255), INDEX(pet_id) ) engine=InnoDB; ALTER TABLE visits ADD CONSTRAINT fk_visits_pets FOREIGN KEY (pet_id) REFERENCES pets(id); Other Spring Framework examples (source code examples)Here is a short list of links related to this Spring Framework initDB.txt source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.