Skip to content

Commit

Permalink
Update solution_Q5.sql, Apply clean code format
Browse files Browse the repository at this point in the history
Apply clean code format

Please accept all changes and rewrite with no mercy!
  • Loading branch information
ArdeshirV authored May 23, 2023
1 parent a254947 commit 91b66e7
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions solution_Q5.sql
Original file line number Diff line number Diff line change
@@ -1,29 +1,35 @@
/* Target: The only requirement of this question is to create and send the table of
the shape mentioned at the beginning of the question after normalization,
using only DDL statements. You must continue normalization until none of
the dependencies are violated. It is not allowed to be NULL in any of the columns.*/
CREATE TABLE capacities (
level int NOT NULL,
capacity bigint NOT NULL,
level int NOT NULL,
capacity bigint NOT NULL,
PRIMARY KEY (level)
);

CREATE TABLE markets (
m_id bigint AUTO_INCREMENT NOT NULL,
m_name varchar(255) NOT NULL,
m_address text NOT NULL,
m_score bigint NOT NULL,
level int NOT NULL,
PRIMARY KEY ( m_id),
m_id bigint AUTO_INCREMENT NOT NULL,
m_name varchar(255) NOT NULL,
m_address text NOT NULL,
m_score bigint NOT NULL,
level int NOT NULL,
PRIMARY KEY (m_id),
FOREIGN KEY (level) REFERENCES capacities(level)
);
);

CREATE TABLE products (
p_id bigint AUTO_INCREMENT NOT NULL,
p_name varchar(255) NOT NULL,
p_weight bigint NOT NULL,
p_id bigint AUTO_INCREMENT NOT NULL,
p_name varchar(255) NOT NULL,
p_weight bigint NOT NULL,
PRIMARY KEY (p_id)
);

CREATE TABLE prices (
price bigint NOT NULL,
p_id bigint NOT NULL,
m_id bigint NOT NULL,
PRIMARY KEY ( m_id,p_id),
price bigint NOT NULL,
p_id bigint NOT NULL,
m_id bigint NOT NULL,
PRIMARY KEY (m_id, p_id),
FOREIGN KEY (p_id) REFERENCES products(p_id),
FOREIGN KEY (m_id) REFERENCES markets (m_id)
);

0 comments on commit 91b66e7

Please sign in to comment.