86 lines
2.3 KiB
MySQL
86 lines
2.3 KiB
MySQL
|
-- Enable foreign key support
|
|||
|
PRAGMA foreign_keys = ON;
|
|||
|
|
|||
|
-- Words table
|
|||
|
CREATE TABLE words (
|
|||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|||
|
spelling TEXT NOT NULL,
|
|||
|
ipa TEXT NOT NULL,
|
|||
|
language_id INTEGER NOT NULL,
|
|||
|
FOREIGN KEY (language_id) REFERENCES languages(id)
|
|||
|
);
|
|||
|
|
|||
|
-- Languages table
|
|||
|
CREATE TABLE languages (
|
|||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|||
|
name TEXT NOT NULL
|
|||
|
);
|
|||
|
|
|||
|
-- Parts of Speech table
|
|||
|
CREATE TABLE parts_of_speech (
|
|||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|||
|
name TEXT NOT NULL
|
|||
|
);
|
|||
|
|
|||
|
-- Categories table (for noun and verb categories)
|
|||
|
CREATE TABLE categories (
|
|||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|||
|
name TEXT NOT NULL,
|
|||
|
part_of_speech_id INTEGER NOT NULL,
|
|||
|
FOREIGN KEY (part_of_speech_id) REFERENCES parts_of_speech(id)
|
|||
|
);
|
|||
|
|
|||
|
-- Word Categories junction table
|
|||
|
CREATE TABLE word_categories (
|
|||
|
word_id INTEGER NOT NULL,
|
|||
|
category_id INTEGER NOT NULL,
|
|||
|
PRIMARY KEY (word_id, category_id),
|
|||
|
FOREIGN KEY (word_id) REFERENCES words(id)
|
|||
|
);
|
|||
|
|
|||
|
-- Example data insertion
|
|||
|
INSERT INTO languages (name) VALUES ('en-us');
|
|||
|
INSERT INTO languages (name) VALUES ('th');
|
|||
|
INSERT INTO languages (name) VALUES ('zh-cn');
|
|||
|
INSERT INTO languages (name) VALUES ('zh-hk');
|
|||
|
INSERT INTO languages (name) VALUES ('ja-jp');
|
|||
|
|
|||
|
INSERT INTO parts_of_speech (name) VALUES ('noun'), ('verb'), ('adjective'), ('adverb'), ('pronoun'), ('adposition'), ('conjunction');
|
|||
|
|
|||
|
INSERT INTO categories (name, part_of_speech_id) VALUES
|
|||
|
('countable', 1),
|
|||
|
('uncountable', 1),
|
|||
|
('animate', 1),
|
|||
|
('inanimate', 1),
|
|||
|
('spatial', 1),
|
|||
|
('temporal', 1),
|
|||
|
('transitive', 2),
|
|||
|
('intransitive', 2),
|
|||
|
('action', 2),
|
|||
|
('mental', 2),
|
|||
|
('preposition', 6),
|
|||
|
('postposition', 6),
|
|||
|
('circumposition', 6);
|
|||
|
|
|||
|
-- Example word insertion
|
|||
|
INSERT INTO words (spelling, ipa, language_id) VALUES ('book', 'bʊk', 1);
|
|||
|
|
|||
|
-- Categorize 'book' as a countable, inanimate noun
|
|||
|
INSERT INTO word_categories (word_id, category_id)
|
|||
|
SELECT
|
|||
|
(SELECT id FROM words WHERE spelling = 'book'),
|
|||
|
id
|
|||
|
FROM categories
|
|||
|
WHERE name IN ('countable', 'inanimate');
|
|||
|
|
|||
|
-- Example verb insertion
|
|||
|
INSERT INTO words (spelling, ipa, language_id) VALUES ('think','θɪŋk', 1);
|
|||
|
|
|||
|
-- Categorize 'think' as an intransitive, mental verb
|
|||
|
INSERT INTO word_categories (word_id, category_id)
|
|||
|
SELECT
|
|||
|
(SELECT id FROM words WHERE spelling = 'think'),
|
|||
|
id
|
|||
|
FROM categories
|
|||
|
WHERE name IN ('intransitive', 'mental');
|