Conversation
xSAVIKx
left a comment
There was a problem hiding this comment.
Please read comments below and fix your implementation.
Additional comment regarding your SQL scripts - there is no need to separate them so much, as it's quite hard to understand in what order they should be executed.
If you want to separate them in such way - create .bat or .sh script, that will handle correct execution order of scripts.
| h2Ds.setUrl(getUrl()); | ||
|
|
||
| Connection conn = h2Ds.getConnection(getUserName(), getPassword()); | ||
| Statement statement = conn.createStatement(); |
There was a problem hiding this comment.
Try to avoid using connections, statements with explicit resource closing.
If there is no need for such declarations - use try-with-resources instead:
try(Connection conn = h2Ds.getConnection(getUserName(), getPassword());
Statement statement = conn.createStatement();){
// some code
}| @@ -0,0 +1,27 @@ | |||
| INSERT INTO PROPERTY(name, value) VALUES ('IRON',100); | |||
There was a problem hiding this comment.
All SQL files should have .sql extension.
| PROPERTY_ID INT, | ||
| CATEGORY_ID INT, | ||
| CATALOG_ID INT, | ||
| FOREIGN KEY (PROPERTY_ID) REFERENCES property(id), |
There was a problem hiding this comment.
From the task README:
One item should contain many properties. Many items may contain the same properties.
With your implementation there is no way to link 2 properties to one item.
| CATEGORY_ID INT, | ||
| CATALOG_ID INT, | ||
| FOREIGN KEY (PROPERTY_ID) REFERENCES property(id), | ||
| FOREIGN KEY (CATEGORY_ID) REFERENCES category(id), |
There was a problem hiding this comment.
From the task README:
One item should be related to many categories. Many items may be related to many categories.
With your implementation there is no way to link item to many categories
| CATALOG_ID INT, | ||
| FOREIGN KEY (PROPERTY_ID) REFERENCES property(id), | ||
| FOREIGN KEY (CATEGORY_ID) REFERENCES category(id), | ||
| FOREIGN KEY (CATALOG_ID) REFERENCES catalog(id) |
There was a problem hiding this comment.
From the task README:
One item may be related to many catalogs. One catalog may contains many items.
With your implementation there is no way to link item to many catalogs
| @@ -0,0 +1,34 @@ | |||
| DROP TABLE IF EXISTS category,property,item,catalog; | |||
There was a problem hiding this comment.
In order to satisfy requirements from README:
- One item should contain many properties. Many items may contain the same properties.
- One item should be related to many categories. Many items may be related to many categories.
- One item may be related to many catalogs. One catalog may contains many items.
you have to create additional tables for relations.
| @@ -0,0 +1,33 @@ | |||
| package school.lemon.changerequest.java.jdbc; | |||
There was a problem hiding this comment.
Please read requirements for Demo class and implement class in a way that:
Create demo class, that creates:
- Several items.
- Several categories.
- Several catalogs.
- Several properties.
- Link items to catalogs, categories, properties.
- Retrieve information about all catalogs, with all items in this catalog. Note that properties and categories of all items should be filled in.
You have to execute SQL statements from Demo class, not from raw .sql files.
hw1