-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add initial version of DB schema #2
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# 002 - Template | ||
|
||
DB Schema by use cases from [001-usecases.md](./usecases.md) | ||
|
||
## Status | ||
|
||
* 2018-04-27: proposed | ||
* 2018-05-09: updated | ||
|
||
## Context | ||
|
||
By the defined use cases in the previous ADR to design a DB schema and describe all data | ||
|
||
## Decision | ||
|
||
* Use RDMS like Postgres | ||
* Initial SQL script like the following: | ||
|
||
```sql | ||
CREATE TABLE person ( | ||
id SERIAL PRIMARY KEY, | ||
login VARCHAR(20) NOT NULL, | ||
name VARCHAR(35) NOT NULL, | ||
email VARCHAR(35) UNIQUE NOT NULL, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's use 64 length for |
||
location VARCHAR(50), | ||
bio VARCHAR, | ||
avatar_url VARCHAR | ||
); | ||
|
||
CREATE TABLE organization ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. looks pretty similar to |
||
id SERIAL PRIMARY KEY, | ||
name VARCHAR(35) NOT NULL, | ||
email VARCHAR(35) UNIQUE NOT NULL, | ||
description VARCHAR, | ||
location VARCHAR(50), | ||
avatar_url VARCHAR | ||
); | ||
|
||
CREATE TABLE membership ( | ||
organization_id INT REFERENCES organization(id), | ||
person_id INT REFERENCES person(id), | ||
role VARCHAR CHECK (role IN ('owner', 'member')), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
CONSTRAINT membership_id PRIMARY KEY (organization_id, person_id) | ||
); | ||
|
||
CREATE TABLE vacancy ( | ||
id SERIAL PRIMARY KEY, | ||
title VARCHAR(30) NOT NULL, | ||
description VARCHAR NOT NULL, | ||
location VARCHAR(50), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. location can be a list of available location There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it can be, but for now it will be simple text, that user type by hands |
||
organization_id INT REFERENCES organization(id) | ||
); | ||
|
||
CREATE TABLE applicant ( | ||
vacancy_id INT REFERENCES vacancy(id), | ||
person_id INT REFERENCES person(id), | ||
CONSTRAINT applicant_id PRIMARY KEY (vacancy_id, person_id) | ||
); | ||
|
||
CREATE TABLE test ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yea, |
||
id SERIAL PRIMARY KEY, | ||
title VARCHAR(30) NOT NULL, | ||
vacancy_id INT REFERENCES vacancy(id) | ||
); | ||
|
||
CREATE TABLE question ( | ||
id SERIAL PRIMARY KEY, | ||
description VARCHAR NOT NULL, | ||
test_id INT REFERENCES test(id), | ||
); | ||
|
||
CREATE TABLE answer ( | ||
id SERIAL PRIMARY KEY, | ||
description VARCHAR NOT NULL, | ||
is_correct BOOLEAN NOT NULL, | ||
question_id INT REFERENCES question(id) | ||
); | ||
|
||
CREATE TABLE test_result ( | ||
id SERIAL PRIMARY KEY, | ||
applicant_id INT REFERENCES applicant(id), | ||
answer_id INT REFERENCES answer(id) | ||
); | ||
``` | ||
|
||
## Consequences | ||
|
||
TBD |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# Summary | ||
|
||
* [001 - Use cases](001-usecases.md) | ||
* [002 - DB Schema](002-db-schema.md) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure about using
login
,name
andemail
togetherThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why? what wrong with it?