Skip to content

Commit

Permalink
Add unique contrain to different tables
Browse files Browse the repository at this point in the history
  • Loading branch information
vkuznet committed Dec 12, 2023
1 parent 8f2996a commit 385d5e0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions web/schemas/mysql.sql
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
CREATE TABLE cycles (
cycle_id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL
name VARCHAR(100) NOT NULL UNIQUE
);

CREATE TABLE beamlines (
beamline_id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL
name VARCHAR(100) NOT NULL UNIQUE
);

CREATE TABLE btrs (
btr_id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL
name VARCHAR(100) NOT NULL UNIQUE
);

CREATE TABLE samples (
sample_id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL
name VARCHAR(100) NOT NULL UNIQUE
);

CREATE TABLE datasets (
Expand All @@ -30,5 +30,5 @@ CREATE TABLE datasets (
CREATE TABLE files (
file_id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
dataset_id BIGINT REFERENCES datasets(dataset_id) ON UPDATE CASCADE,
name VARCHAR(100) NOT NULL
name VARCHAR(100) NOT NULL UNIQUE
);
10 changes: 5 additions & 5 deletions web/schemas/sqlite.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@

CREATE TABLE cycles (
cycle_id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL
name TEXT NOT NULL UNIQUE
);

CREATE TABLE beamlines (
beamline_id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL
name TEXT NOT NULL UNIQUE
);

CREATE TABLE btrs (
btr_id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL
name TEXT NOT NULL UNIQUE
);

CREATE TABLE samples (
sample_id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL
name TEXT NOT NULL UNIQUE
);

CREATE TABLE datasets (
Expand All @@ -32,6 +32,6 @@ CREATE TABLE datasets (
CREATE TABLE files (
file_id INTEGER PRIMARY KEY AUTOINCREMENT,
dataset_id INTEGER REFERENCES datasets(dataset_id) ON UPDATE CASCADE,
name TEXT NOT NULL
name TEXT NOT NULL UNIQUE
);

0 comments on commit 385d5e0

Please sign in to comment.