ringfinger/backend/scripts/setup.sql

38 lines
1.3 KiB
MySQL
Raw Normal View History

2020-08-19 23:45:39 +02:00
START TRANSACTION;
USE ringfinger;
CREATE TABLE User (
UserId int(10) unsigned NOT NULL AUTO_INCREMENT,
Username varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL,
Password varchar(128) COLLATE utf8mb4_unicode_ci NOT NULL,
Email varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
JabberAddress varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
PRIMARY KEY (UserId),
UNIQUE KEY Username (Username),
UNIQUE KEY Email (Email),
UNIQUE KEY JabberAddress (JabberAddress)
);
CREATE TABLE Fingerprint (
FingerprintId int(10) unsigned NOT NULL AUTO_INCREMENT,
Fingerprint varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
UserId int(10) unsigned NOT NULL,
PRIMARY KEY (FingerprintId),
UNIQUE KEY Fingerprint (Fingerprint),
KEY User (UserId),
2020-08-20 22:28:22 +02:00
CONSTRAINT User FOREIGN KEY (UserId) REFERENCES User (UserId) ON DELETE CASCADE
2020-08-19 23:45:39 +02:00
);
CREATE TABLE Sharing (
SharingId int(10) unsigned NOT NULL AUTO_INCREMENT,
User int(10) unsigned NOT NULL,
UserShared int(10) unsigned NOT NULL,
PRIMARY KEY (SharingId),
UNIQUE KEY User (User, UserShared),
KEY UserSharedId (UserShared),
2020-08-20 22:28:22 +02:00
CONSTRAINT UserId FOREIGN KEY (User) REFERENCES User (UserId) ON DELETE CASCADE,
CONSTRAINT UserSharedId FOREIGN KEY (UserShared) REFERENCES User (UserId) ON DELETE CASCADE
2020-08-19 23:45:39 +02:00
);
COMMIT;