0% found this document useful (0 votes)
4 views2 pages

Java SQL Logiciel

The document outlines SQL commands to create a database named 'recipe_db' with UTF-8 character encoding. It includes the creation of three tables: 'recipes', 'ingredients', and 'steps', each with specific fields and relationships. Foreign keys are established to maintain referential integrity between the tables.

Uploaded by

fundid856
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Java SQL Logiciel

The document outlines SQL commands to create a database named 'recipe_db' with UTF-8 character encoding. It includes the creation of three tables: 'recipes', 'ingredients', and 'steps', each with specific fields and relationships. Foreign keys are established to maintain referential integrity between the tables.

Uploaded by

fundid856
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Java_SQL

1.

CREATE DATABASE IF NOT EXISTS recipe_db

CHARACTER SET utf8mb4

COLLATE utf8mb4_unicode_ci;

USE recipe_db;

CREATE TABLE IF NOT EXISTS recipes (

id INT AUTO_INCREMENT PRIMARY KEY,

title VARCHAR(255) NOT NULL,

category VARCHAR(100),

preparation_time INT DEFAULT 0,

cooking_time INT DEFAULT 0,

servings INT DEFAULT 1,

difficulty VARCHAR(50),

image_path VARCHAR(500),

created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,

updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP

) ENGINE=InnoDB;

CREATE TABLE IF NOT EXISTS ingredients (

id INT AUTO_INCREMENT PRIMARY KEY,

recipe_id INT NOT NULL,

name VARCHAR(255) NOT NULL,


quantity DECIMAL(10,2),

unit VARCHAR(50),

notes TEXT,

FOREIGN KEY (recipe_id) REFERENCES recipes(id) ON DELETE CASCADE

) ENGINE=InnoDB;

CREATE TABLE IF NOT EXISTS steps (

id INT AUTO_INCREMENT PRIMARY KEY,

recipe_id INT NOT NULL,

step_number INT NOT NULL,

description TEXT NOT NULL,

duration INT DEFAULT 0,

FOREIGN KEY (recipe_id) REFERENCES recipes(id) ON DELETE CASCADE

) ENGINE=InnoDB;

You might also like