-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update solution_Q5.sql, Apply clean code format
Apply clean code format Please accept all changes and rewrite with no mercy!
- Loading branch information
Showing
1 changed file
with
22 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
); |