Skip to content
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

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions 001-usecases.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Interviewr is an app to simplify and enhance interview process
## Status

* 2018-04-21: proposed
* 2018-04-22: accepted

## Context

Expand Down
88 changes: 88 additions & 0 deletions 002-db-schema.md
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,
Copy link
Member Author

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 and email together

Copy link
Member

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?

name VARCHAR(35) NOT NULL,
email VARCHAR(35) UNIQUE NOT NULL,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's use 64 length for login, name, and email

location VARCHAR(50),
bio VARCHAR,
avatar_url VARCHAR
);

CREATE TABLE organization (
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks pretty similar to person table

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')),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

owner or admin?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

admin sounds reasonable and better

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),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

location can be a list of available location

Copy link
Member

Choose a reason for hiding this comment

The 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 (
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test or quiz?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea, quiz suits better

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
1 change: 1 addition & 0 deletions SUMMARY.md
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)