source: other-projects/the-macronizer/trunk/src/sql-scripts/MySQL_Code.sql@ 32745

Last change on this file since 32745 was 32745, checked in by ak19, 5 years ago

More Western Wilson stuff. 1. Major changes to fix handling of utf8 stuff in db so uniqueness actually works: so finding (selecting) exact matches works and insert unique violations don't happen from code. Inserting is now made lowercase since only macrons matter and case doesn't. 2. The SQL db's MarkedWords table needs to specify the uniqueness of its utf8 marked_word column differently for the utf8-ness to work.

File size: 1.1 KB
Line 
1SET names utf8mb4;
2
3CREATE database Macroniser;
4
5USE Macroniser;
6
7
8/*
9Unique constraint on marked_word field needs to be specified specially to deal with utf8
10e.g. to distinguish between āno and anō, rather than treating them both the same breaking uniqueness.
11https://stackoverflow.com/questions/25318479/unique-constraint-violation-with-utf-8-values
12*/
13CREATE TABLE IF NOT EXISTS MarkedWords (
14 word_id INT AUTO_INCREMENT,
15 marked_word varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin UNIQUE,
16 PRIMARY KEY (word_id)
17 );
18
19CREATE TABLE IF NOT EXISTS EntryTimes (
20 time_id INT AUTO_INCREMENT,
21 entry_time TIME NOT NULL UNIQUE,
22 PRIMARY KEY (time_id)
23 );
24
25CREATE TABLE IF NOT EXISTS EntryDates (
26 date_id INT AUTO_INCREMENT,
27 entry_date DATE NOT NULL UNIQUE,
28 PRIMARY KEY (date_id)
29 );
30
31CREATE TABLE IF NOT EXISTS Occurrences (
32 occurrence_id INT AUTO_INCREMENT,
33 word_id INT,
34 time_id INT,
35 date_id INT,
36 PRIMARY KEY (occurrence_id),
37 FOREIGN KEY (word_id) REFERENCES MarkedWords(word_id),
38 FOREIGN KEY (time_id) REFERENCES EntryTimes(time_id),
39 FOREIGN KEY (date_id) REFERENCES EntryDates(date_id)
40 );
Note: See TracBrowser for help on using the repository browser.