Skip to content

Comments

hw1#1

Open
VynnykVV wants to merge 1 commit intoChangeRequest:masterfrom
VynnykVV:master
Open

hw1#1
VynnykVV wants to merge 1 commit intoChangeRequest:masterfrom
VynnykVV:master

Conversation

@VynnykVV
Copy link

hw1

@xSAVIKx xSAVIKx self-assigned this Mar 19, 2017
Copy link
Member

@xSAVIKx xSAVIKx left a comment

Choose a reason for hiding this comment

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

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();
Copy link
Member

Choose a reason for hiding this comment

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

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

Choose a reason for hiding this comment

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

All SQL files should have .sql extension.

PROPERTY_ID INT,
CATEGORY_ID INT,
CATALOG_ID INT,
FOREIGN KEY (PROPERTY_ID) REFERENCES property(id),
Copy link
Member

Choose a reason for hiding this comment

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

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

Choose a reason for hiding this comment

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

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

Choose a reason for hiding this comment

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

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;
Copy link
Member

Choose a reason for hiding this comment

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

In order to satisfy requirements from README:

  1. One item should contain many properties. Many items may contain the same properties.
  2. One item should be related to many categories. Many items may be related to many categories.
  3. 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;
Copy link
Member

Choose a reason for hiding this comment

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

Please read requirements for Demo class and implement class in a way that:

Create demo class, that creates:

  1. Several items.
  2. Several categories.
  3. Several catalogs.
  4. Several properties.
  5. Link items to catalogs, categories, properties.
  6. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants