38 lines
1.3 KiB
SQL
38 lines
1.3 KiB
SQL
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),
|
|
CONSTRAINT User FOREIGN KEY (UserId) REFERENCES User (UserId) ON DELETE CASCADE
|
|
);
|
|
|
|
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),
|
|
CONSTRAINT UserId FOREIGN KEY (User) REFERENCES User (UserId) ON DELETE CASCADE,
|
|
CONSTRAINT UserSharedId FOREIGN KEY (UserShared) REFERENCES User (UserId) ON DELETE CASCADE
|
|
);
|
|
|
|
COMMIT; |