Segue a resolução do exercicio proposto.
CREATE TABLE CLIENTES(
ID_CLIENTE INTEGER PRIMARY KEY AUTOINCREMENT,
NOME VARCHAR (150) NOT NULL,
EMAIL VARCHAR (150) NOT NULL UNIQUE
);
CREATE TABLE PEDIDOS(
ID_PEDIDO INTEGER PRIMARY KEY AUTOINCREMENT,
FKID_CLIENTE INTEGER,
DATAPEDIDO DATE,
FOREIGN KEY(FKID_CLIENTE) REFERENCES CLIENTES(ID_CLIENTE)
);
INSERT INTO Clientes (ID_CLIENTE, NOME, EMAIL) VALUES (1, 'Ana Silva', 'ana.silva@example.com'),
(2, 'Bruno Souza', 'bruno.souza@example.com'),
(3, 'Carlos Oliveira', 'carlos.oliveira@example.com'),
(4, 'Daniela Mendes', 'daniela.mendes@example.com'),
(5, 'Eduardo Lima', 'eduardo.lima@example.com'),
(6, 'Fernanda Ferreira', 'fernanda.ferreira@example.com'),
(7, 'Gabriel Costa', 'gabriel.costa@example.com'),
(8, 'Helena Martins', 'helena.martins@example.com'),
(9, 'Igor Ribeiro', 'igor.ribeiro@example.com'),
(10, 'Juliana Almeida', 'juliana.almeida@example.com'),
(11, 'Karen Lopes', 'karen.lopes@example.com'),
(12, 'Lucas Pereira', 'lucas.pereira@example.com'),
(13, 'Mariana Rocha', 'mariana.rocha@example.com'),
(14, 'Nicolas Moreira', 'nicolas.moreira@example.com'),
(15, 'Olivia Cardoso', 'olivia.cardoso@example.com');
INSERT INTO Pedidos (ID_PEDIDO, FKID_CLIENTE, DATAPEDIDO) VALUES (1, 1, '2024-07-01'),
(2, 2, '2024-07-02'),
(3, 3, '2024-07-03'),
(4, 4, '2024-07-04'),
(5, 5, '2024-07-05'),
(6, 6, '2024-07-06'),
(7, 7, '2024-07-07'),
(8, 8, '2024-07-08'),
(9, 9, '2024-07-09'),
(10, 10, '2024-07-10');
SELECT * FROM PEDIDOS;
SELECT * FROM CLIENTES;
SELECT CL.NOME, PD.ID_PEDIDO, PD.DATAPEDIDO
FROM PEDIDOS AS PD
RIGHT JOIN CLIENTES AS CL
ON CL.ID_CLIENTE = PD.FKID_CLIENTE
WHERE PD.FKID_CLIENTE ISNULL;