diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..ab1f416
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,10 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Ignored default folder with query files
+/queries/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
+# Editor-based HTTP Client requests
+/httpRequests/
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..bf2c501
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..aa00ffa
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
new file mode 100644
index 0000000..a9076af
--- /dev/null
+++ b/.idea/jarRepositories.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..5e4e294
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/database.sql b/database.sql
index 2169346..2163938 100644
--- a/database.sql
+++ b/database.sql
@@ -8,7 +8,10 @@
-- 5. Insert at least 3 menu items.
-- 6. The script should be executable from start to finish without errors.
-
+DROP TABLE IF EXISTS order_details CASCADE;
+DROP TABLE IF EXISTS orders CASCADE;
+DROP TABLE IF EXISTS menu_items CASCADE;
+DROP TABLE IF EXISTS users CASCADE;
-- =======================================================
-- USER TABLE
@@ -28,8 +31,12 @@
-- - Username and password are required.
-- - Passwords should not be stored in plain text.
--
--- CREATE TABLE ...
-
+CREATE TABLE users (
+ id SERIAL PRIMARY KEY,
+ username VARCHAR(50) UNIQUE NOT NULL,
+ password VARCHAR(255) NOT NULL,
+ email VARCHAR(100)
+);
-- =======================================================
@@ -50,8 +57,13 @@
-- - Name is required.
-- - Price must always be positive.
--
--- CREATE TABLE ...
-
+CREATE TABLE menu_items (
+ id SERIAL PRIMARY KEY,
+ name VARCHAR(100) NOT NULL,
+ description TEXT,
+ price NUMERIC(10, 2) NOT NULL CHECK (price > 0),
+ category VARCHAR(50)
+);
-- =======================================================
@@ -75,8 +87,12 @@
-- Avoid using reserved SQL keywords as table names.
-- Consider using a name such as "orders" or "customer_orders".
--
--- CREATE TABLE ...
-
+CREATE TABLE orders (
+ id SERIAL PRIMARY KEY,
+ user_id INT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
+ created_at TIMESTAMP NOT NULL,
+ total_price NUMERIC(10, 2) NOT NULL DEFAULT 0.00
+);
-- =======================================================
@@ -98,8 +114,13 @@
-- - Quantity must always be greater than zero.
-- - Store the item's price at the moment of purchase.
--
--- CREATE TABLE ...
-
+CREATE TABLE order_details (
+ id SERIAL PRIMARY KEY,
+ order_id INT NOT NULL REFERENCES orders(id) ON DELETE CASCADE,
+ menu_item_id INT NOT NULL REFERENCES menu_items(id),
+ quantity INT NOT NULL CHECK (quantity > 0),
+ price NUMERIC(10, 2) NOT NULL
+);
-- =======================================================
@@ -114,8 +135,11 @@
-- - Pasta
-- - Drink
--
--- INSERT INTO ...
-
+INSERT INTO menu_items (name, description, price, category) VALUES
+('Pizza', 'Delicious cheese pizza with tomato sauce', 10.00, 'Pizza'),
+('Burger', 'Juicy beef burger with lettuce and tomato', 8.00, 'Burger'),
+('Pasta', 'Rich creamy Alfredo pasta', 12.00, 'Pasta'),
+('Soda', 'Cold carbonated drink', 2.50, 'Drink');
-- =======================================================
@@ -125,8 +149,6 @@
-- You may insert sample users and orders for testing.
-- This section is optional.
--
--- INSERT INTO ...
-
-- =======================================================
@@ -135,7 +157,7 @@
--
-- Uncomment these queries to verify your database.
--
--- SELECT * FROM ...;
--- SELECT * FROM ...;
--- SELECT * FROM ...;
--- SELECT * FROM ...;
\ No newline at end of file
+SELECT * FROM users;
+SELECT * FROM menu_items;
+SELECT * FROM orders;
+SELECT * FROM order_details;
\ No newline at end of file
diff --git a/src/main/java/dev/dao/MenuItemDao.java b/src/main/java/dev/dao/MenuItemDao.java
index 3bbebe9..d5adb25 100644
--- a/src/main/java/dev/dao/MenuItemDao.java
+++ b/src/main/java/dev/dao/MenuItemDao.java
@@ -1,25 +1,57 @@
package dev.dao;
+import dev.database.DatabaseConnection;
import dev.model.MenuItem;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
import java.util.List;
public class MenuItemDao {
public List