What You Will Learn about SQL


SQL

Introduction to SQL

In this training, you will learn how to create and manage MySQL databases, transfer data from Excel, and understand fundamental data management concepts.


Project Steps:

Create a Database

Introduction

This section will guide you through the process of creating a MySQL database using standard SQL commands.


Tables

We will create the following tables for our sales management project:

- Clients
- Products
- Customer_Satisfaction
- Sales

Create a Database

1- Création de la base de données

SQL Console
CREATE DATABASE VenteAuDetail;
USE VenteAuDetail;

2- Création de la table Clients

SQL Console
CREATE TABLE Clients (
  Client_ID INT PRIMARY KEY,
  Nom VARCHAR(100),
  Age INT,
  Genre CHAR(1),
  Ville VARCHAR(100)
);

3- Création de la table Produits

SQL Console
CREATE TABLE Produits (
  Produit_ID INT PRIMARY KEY,
  Nom_Produit VARCHAR(100),
  Categorie VARCHAR(50),
  Prix_Unitaire DECIMAL(10, 2),
  Stock INT
);

4- Création de la table Ventes

SQL Console
CREATE TABLE Ventes (
  Vente_ID INT PRIMARY KEY,
  Date DATE NOT NULL,
  Client_ID INT,
  Produit_ID INT,
  QUantite INT,
  Prix_Unitaire DECIMAL(10, 2),
  Montant_Total DECIMAL(10, 2),
  FOREIGN KEY (Client_ID) REFERENCES Clients(Client_ID),
  FOREIGN KEY (Produit_ID) REFERENCES Produits(Produit_ID)
);

5- Création de la table Satisfaction_Client

SQL Console
CREATE TABLE Satisfaction_Client (
  Satisfaction_ID INT PRIMARY KEY,
  Client_ID INT,
  Vente_ID INT,
  Evaluation INT CHECK (Evaluation BETWEEN 1 AND 5 ),
  Commentaires TEXT,
  FOREIGN KEY (Client_ID) REFERENCES Clients(Client_ID),
  FOREIGN KEY (Vente_ID) REFERENCES Ventes(Vente_ID)
);

Transfer Data from Excel to a MySQL Database

Transférer les données d'un fichier Excel vers une base de données MySQL.