Question: create Entity relationship of the database below postgresql draw it fully showing all connections and key the lecturer provided a model answer so please refer

create Entity relationship of the database below postgresql draw it fully showing all connections and key the lecturer provided a model answer so please refer to it in the photoDiagram of Database Models Implemented but with using my database example below- Create staff table (insure all staff usernames are unique)
CREATE TABLE staff(
staff_id SERIAL PRIMARY KEY,
staff_name VARCHAR(255) UNIQUE NOT NULL,
staff_pin INT NOT NULL,
staff_type INT NOT NULL
);
-- Create customer table
CREATE TABLE customer(
customer_id SERIAL PRIMARY KEY,
customer_name VARCHAR(255) NOT NULL,
customer_allergies TEXT
);
-- Create menu table
CREATE TABLE menu(
dish_id SERIAL PRIMARY KEY,
dish_name VARCHAR(255) NOT NULL,
dish_calories INT NOT NULL,
dish_price DECIMAL(10,2) NOT NULL,
dish_description VARCHAR(1000)
);
CREATE TABLE allergens(
allergen_id SERIAL PRIMARY KEY,
allergen_name VARCHAR(255)
);
GRANT ALL ON allergens TO root;
INSERT INTO allergens (allergen_name) VALUES ('Gluten');
INSERT INTO allergens (allergen_name) VALUES ('Dairy');
INSERT INTO allergens (allergen_name) VALUES ('Nuts');
--create table relation for menu items and allergens
CREATE TABLE dish_allergens (
dish_id INT,
allergen_id INT,
FOREIGN KEY (dish_id) REFERENCES menu(dish_id) ON DELETE CASCADE,
FOREIGN KEY (allergen_id) REFERENCES allergens(allergen_id) ON DELETE CASCADE
);
GRANT ALL ON orders TO root;
CREATE TABLE order_details (
order_detail_id SERIAL PRIMARY KEY,
order_id INT REFERENCES orders(order_id) ON DELETE CASCADE,
dish_id INT REFERENCES menu(dish_id) ON DELETE CASCADE,
quantity INT
);
GRANT ALL ON order_details TO root;
-- Create needs_help table
CREATE TABLE needs_help (
help_id SERIAL PRIMARY KEY,
customer_id SERIAL REFERENCES customer(customer_id) ON DELETE CASCADE,
resolved BOOLEAN DEFAULT FALSE
);
GRANT ALL ON needs_help TO root;
CREATE TABLE tables (
table_number SERIAL PRIMARY KEY,
customer_id INT REFERENCES customer(customer_id) ON DELETE CASCADE,
staff_id INT REFERENCES staff(staff_id) ON DELETE CASCADE
);
GRANT ALL ON tables TO root;
CREATE TABLE payments (
payment_id SERIAL PRIMARY KEY,
payment_time TIMESTAMP NOT NULL,
payment_amount NUMERIC(10,2) NOT NULL,
table_number SERIAL REFERENCES tables(table_number) ON DELETE CASCADE,
card_holder VARCHAR(255),
card_ending INT,
card_expiry VARCHAR(5)
);
GRANT ALL ON payments TO root; note that this questions was not answered before so please focus as the answer provided was incomplete. thank u
 create Entity relationship of the database below postgresql draw it fully

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!