delete from MenuItems;
insert into MenuItems (MenuItemID, Name, Category, Price) values
(1, "Grilled Artichokes", "Starter", 6.00),
(2, "Lentil Soup", "Starter", 7.00),
(3, "Humus Plate", "Starter", 6.00),
(4, "Eggplant Bruschetta", "Starter", 7.00),
(5, "Gigantes Plaki", "Main", 14.00),
(6, "Minestrone", "Main", 16.00),
(7, "Moussaka", "Main", 17.00),
(8, "Pasta alla Norma", "Main", 12.00),
(9, "Tabbouleh", "Salad", 8.00),
(10, "Green Bean Salad", "Salad", 8.00),
(11, "Tomato Salad", "Salad", 9.50),
(12, "Fennel Salad", "Salad", 8.50),
(13, "Fruit Salad", "Desert", 7.00),
(14, "Roasted Grapes", "Desert", 6.50),
(15, "Grilled Mango", "Desert", 8.50),
(16, "Grilled Waterlemon", "Desert", 8.50);

delete from Addresses;
insert into Addresses (AddressID, Street, PostalCode, City, Country) values
(1, 'Hauptstraße 1', '10115', 'Berlin', 'Germany'),
(2, 'Friedrichstraße 56', '10119', 'Berlin', 'Germany'),
(3, 'Kurfürstenstraße 135', '10115', 'Berlin', 'Germany'),
(4, 'Altenhofen 168', '10623', 'Berlin', 'Germany'),
(5, 'Hauptstraße 180', '10116', 'Berlin', 'Germany');

delete from Employees;
insert into Employees (
    EmployeeID, FirstName, LastName, PhoneNumber, EmailAddress, Role, AnnualSalary, AddressID
) values
(1, 'Mario', 'Gollini', '+4915123456789', 'mario.gollini@littlelemon.de', 'Manager', 72383.00, 1),
(2, 'Adrian', 'Gollini', '+4916198765432', 'adrian.gollini@littlelemon.de', 'Receptionist', 74083.00, 2),
(3, 'Giorgos', 'Dioudis', '+4917654321098', 'giogos.dioudis@littlelemon.de', 'Assistant Chef', 77912.00, 3),
(4, 'Fatma', 'Kaya', '+4918765432190', 'fatma.kaya@littlelemon.de', 'Head Chef', 79314.00, 4),
(5, 'Elena', 'Salvai', '+4919876543210', 'elena.salvai@littlelemon.de', 'Waiter', 78921.00, 5);

delete from Customers;
insert into Customers (
    CustomerID, FirstName, LastName, PhoneNumber, EmailAddress, AddressID
)
values
(1, 'Ahmed', 'Mohamed', '+20212345678', 'ahmed.mohamed@example.com', null),
(2, 'Sophie', 'Dupont', '+33612345678', 'sophie.dupont@example.com', null),
(3, 'Li Wei', 'Zhang', '+86123456789', 'li.wei.zhang@example.com', null),
(4, 'Maria', 'Rodriguez', '+34612345678', 'maria.rodriguez@example.com', null),
(5, 'Ivanov', 'Petrov', '+70987654321', 'ivanov.petrov@example.com', null),
(6, 'José', 'Martinez', '+54987654321', 'jose.martinez@example.com', null),
(7, 'Maria', 'Schmidt', '+49987654321', 'maria.schmidt@example.com', null),
(8, 'Thomas', 'Müller', '+44987654321', 'thomas.mueller@example.com', null),
(9, 'Ramón', 'García', '+58987654321', 'ramon.garcia@example.com', null),
(10, 'Lee', 'Kim', '+82109876543', 'lee.kim@example.com', null);

delete from Bookings;
insert into Bookings (BookingID, Reserved, TableNumber, CustomerID, EmployeeID)
values
(1, '2024-11-14 18:00:00', 1, 3, 1),
(2, '2024-11-14 19:30:00', 2, 2, 1),
(3, '2024-11-14 18:45:00', 3, 4, 1),
(4, '2024-11-14 19:15:00', 4, 1, 2),
(5, '2024-11-14 18:30:00', 5, 6, 2),
(6, '2024-11-14 19:00:00', 6, 5, 2),
(7, '2024-11-15 18:15:00', 1, 7, 5),
(8, '2024-11-15 19:45:00', 2, 8, 5),
(9, '2024-11-15 18:30:00', 3, 9, 2),
(10, '2024-11-15 19:00:00', 4, 10, 5);

insert into Orders (OrderID, Started, Finished, BillAmount, BookingID)
values
(1, '2024-11-14 18:05:00', '2023-10-01 19:25:00', null, 1),
(2, '2024-11-14 19:35:00', '2023-10-02 20:45:00', null, 2),
(3, '2024-11-14 19:10:00', '2023-10-03 20:30:00', null, 3),
(4, '2024-11-14 19:35:00', '2023-10-04 20:50:00', null, 4),
(5, '2024-11-14 19:40:00', '2023-10-05 20:55:00', null, 5),
(6, '2024-11-14 19:40:00', '2023-10-06 20:45:00', null, 6);

insert into OrderItems (OrderItemID, MenuItemID, OrderID, Ordered, Delivered, DeliveryStatus)
values
(1, 1, 1, '2024-11-14 18:05:00', '2024-11-14 18:25:00', 'Delivered'),
(2, 2, 1, '2024-11-14 18:05:00', '2024-11-14 18:25:00', 'Delivered'),
(3, 3, 1, '2024-11-14 18:05:00', '2024-11-14 18:25:00', 'Delivered'),
(4, 5, 1, '2024-11-14 18:05:00', '2024-11-14 18:40:00', 'Delivered'),
(5, 5, 1, '2024-11-14 18:05:00', '2024-11-14 18:40:00', 'Delivered'),
(6, 8, 1, '2024-11-14 18:05:00', '2024-11-14 18:40:00', 'Delivered'),
(7, 14, 1, '2024-11-14 18:05:00', '2024-11-14 19:05:00', 'Delivered'),
(8, 15, 1, '2024-11-14 18:05:00', '2024-11-14 19:05:00', 'Delivered'),
(9, 16, 1, '2024-11-14 18:05:00', '2024-11-14 19:05:00', 'Delivered'),
(10, 2, 2, '2024-11-14 19:35:00', '2024-11-14 19:55:00', 'Delivered'),
(11, 5, 2, '2024-11-14 19:35:00', '2024-11-14 20:10:00', 'Delivered'),
(12, 13, 2, '2024-11-14 19:35:00', '2024-11-14 20:35:00', 'Delivered'),
(13, 4, 3, '2024-11-14 19:10:00', '2024-11-14 19:30:00', 'Delivered'),
(14, 7, 3, '2024-11-14 19:10:00', '2024-11-14 19:45:00', 'Delivered'),
(15, 13, 3, '2024-11-14 19:10:00', '2024-11-14 20:10:00', 'Delivered'),
(16, 3, 4, '2024-11-14 19:35:00', '2024-11-14 19:55:00', 'Delivered'),
(17, 6, 4, '2024-11-14 19:35:00', '2024-11-14 20:10:00', 'Delivered'),
(18, 13, 4, '2024-11-14 19:35:00', '2024-11-14 20:35:00', 'Delivered'),
(19, 9, 5, '2024-11-14 19:40:00', '2024-11-14 20:00:00', 'Delivered'),
(20, 8, 5, '2024-11-14 19:40:00', '2024-11-14 20:15:00', 'Delivered'),
(22, 2, 6, '2024-11-14 19:40:00', '2024-11-14 19:55:00', 'Delivered'),
(23, 4, 6, '2024-11-14 19:40:00', '2024-11-14 19:55:00', 'Delivered'),
(24, 2, 6, '2024-11-14 19:40:00', '2024-11-14 19:55:00', 'Delivered'),
(25, 3, 6, '2024-11-14 19:40:00', '2024-11-14 19:55:00', 'Delivered'),
(26, 1, 6, '2024-11-14 19:40:00', '2024-11-14 19:55:00', 'Delivered'),
(27, 6, 6, '2024-11-14 19:40:00', '2024-11-14 20:10:00', 'Delivered'),
(28, 6, 6, '2024-11-14 19:40:00', '2024-11-14 20:10:00', 'Delivered'),
(29, 5, 6, '2024-11-14 19:40:00', '2024-11-14 20:10:00', 'Delivered'),
(30, 5, 6, '2024-11-14 19:40:00', '2024-11-14 20:10:00', 'Delivered'),
(31, 7, 6, '2024-11-14 19:40:00', '2024-11-14 20:10:00', 'Delivered'),
(32, 15, 6, '2024-11-14 19:40:00', '2024-11-14 20:35:00', 'Delivered'),
(33, 14, 6, '2024-11-14 19:40:00', '2024-11-14 20:35:00', 'Delivered'),
(34, 15, 6, '2024-11-14 19:40:00', '2024-11-14 20:35:00', 'Delivered'),
(35, 16, 6, '2024-11-14 19:40:00', '2024-11-14 20:35:00', 'Delivered'),
(36, 16, 6, '2024-11-14 19:40:00', '2024-11-14 20:35:00', 'Delivered');

update Orders as O
inner join
    (
        select
            OI.OrderID,
            sum(MI.Price) as TotalItemPrice
        from OrderItems as OI
        inner join MenuItems as MI on OI.MenuItemID = MI.MenuItemID
        group by OI.OrderID
    ) as A
    on O.OrderID = A.OrderID
set O.BillAmount = A.TotalItemPrice;
