Database

Me : please explain how to set up a database in a plesk server to store image-names and the list of emotions that you suggested above with the numbers that a specific emotion has been attributed to an image by anonymous viewers.


ChatGPT-4o : To set up a database on a Plesk server to store image names and track how many times each emotion has been attributed to a specific image by anonymous viewers, follow these steps:


Step 1: Access Plesk and Create the Database

  1. Log into your Plesk panel.
  2. Go to Databases from the left-hand menu (or via the domain’s dashboard).
  3. Click “Add Database”.
    • Database name: e.g., image_emotions_db
    • Related site: Choose your domain
    • Database user: Create a username and password (save these)
  4. Click OK to create the database.

Step 2: Design the Database Structure

You’ll need two main tables:

1. images

Stores the list of images.

Field NameTypeDescription
idINT (PK)Auto-increment ID
image_nameVARCHAR(255)Name or path of the image

Step 3: Create the Tables

Use phpMyAdmin via Plesk or run SQL manually.

SQL Script Example:

CREATE TABLE images (
    id INT AUTO_INCREMENT PRIMARY KEY,
    image_name VARCHAR(255) NOT NULL
);

CREATE TABLE emotion_counts (
    id INT AUTO_INCREMENT PRIMARY KEY,
    image_id INT NOT NULL,
    emotion VARCHAR(50) NOT NULL,
    count INT DEFAULT 0,
    FOREIGN KEY (image_id) REFERENCES images(id)
);

Step 4: Insert Emotion Options

Insert a row for each image and each emotion with count = 0.

Example (for one image):

INSERT INTO images (image_name) VALUES ('sunset_001.jpg');
SET @img_id = LAST_INSERT_ID();

INSERT INTO emotion_counts (image_id, emotion)
VALUES
(@img_id, 'Joy'),
(@img_id, 'Sadness'),
(@img_id, 'Inspiration'),
(@img_id, 'Fear'),
(@img_id, 'Nostalgia'),
(@img_id, 'Wonder'),
(@img_id, 'Confusion'),
(@img_id, 'Disgust'),
(@img_id, 'Serenity'),
(@img_id, 'Fascination');

Step 5: Frontend Integration (Optional)

Create a simple form or buttons on your website for each image, allowing users to select how they feel about the image. Each click would:

  1. Send an AJAX or POST request.
  2. Update the emotion_counts.count field for the selected emotion and image.

Step 6: Track and Display Data

You can use SQL queries to show results like:

SELECT emotion, count FROM emotion_counts
WHERE image_id = 1
ORDER BY count DESC;

This will show which emotions were most attributed to a given image.