estou com problemas em fazer com que no meu select as chaves primas busquem automaticamente nos outros registros, a seguir o código em ddl e dml.`DROP DATABASE IF EXISTS academia;
CREATE DATABASE academia;
USE academia;
DROP TABLE IF EXISTS aluno;
CREATE TABLE aluno(
codMatricula int unsigned not null auto_increment,
turma_idturma int unsigned,
dataMatricula date not null,
nome varchar(45) not null,
endereço text,
telefone int,
dataNascimento date not null,
altura double,
peso double,
PRIMARY KEY (codMatricula),
CONSTRAINT tuma_cod_fk FOREIGN KEY (turma_idturma) REFERENCES turma (idturma)
);
DROP TABLE IF EXISTS matricula;
CREATE TABLE matricula(
aluno_codMatricula int unsigned auto_increment,
turma_idturma int unsigned,
PRIMARY KEY(aluno_codMatricula),
CONSTRAINT turma_id_fk FOREIGN KEY (turma_idturma) REFERENCES turma (idturma),
CONSTRAINT aluno_id_fk FOREIGN KEY (aluno_codMatricula) REFERENCES aluno (codMatriculo)
);
DROP TABLE IF EXISTS turma;
CREATE TABLE turma(
idturma int unsigned default 1,
horario time not null,
duracao int unsigned not null,
dataInicio date not null,
dataFim date NULL,
atividade_idatividade int unsigned,
instrutor_idinstrutor int unsigned,
PRIMARY KEY(idturma),
CONSTRAINT cod_fk FOREIGN KEY (atividade_idatividade) REFERENCES atividade (idatividade),
CONSTRAINT atvd_fk FOREIGN KEY (instrutor_idinstrutor) REFERENCES instrutor (idinstrutor)
);
DROP TABLE IF EXISTS instrutor;
CREATE TABLE instrutor(
idinstrutor int unsigned not null auto_increment,
rg int unsigned not null,
nome varchar(45) not null,
nascimento date,
titulacao int,
PRIMARY KEY(idinstrutor)
);
DROP TABLE IF EXISTS telefone_instrutor;
CREATE TABLE telefone_instrutor(
idtelefone int unsigned not null auto_increment,
numero int not null,
tipo varchar(45),
instrutor_idinstrutor int unsigned not null,
PRIMARY KEY(idtelefone),
CONSTRAINT tel_fk FOREIGN KEY (instrutor_idinstrutor) REFERENCES instrutor (idinstrutor)
);
DROP TABLE IF EXISTS chamada;
CREATE TABLE chamada(
idchamada int unsigned not null auto_increment,
dataa date not null,
presente char(3) not null,
matricula_aluno_codMatricula int unsigned,
matricula_turma_idturma int unsigned ,
PRIMARY KEY(idchamada),
CONSTRAINT matricula_fk FOREIGN KEY (matricula_aluno_codMatricula) REFERENCES aluno (codMatricula),
CONSTRAINT turma_matricula_fk FOREIGN KEY (matricula_turma_idturma) REFERENCES turma (idturma)
);
DROP TABLE IF exists atividade;
CREATE TABLE atividade(
idatividade int unsigned not null auto_increment,
nome varchar(100),
PRIMARY KEY(idatividade)
);
fim DDL
`use academia;
INSERT INTO aluno (turma_idturma, dataMatricula, nome, endereço, telefone, dataNascimento, altura, peso)
VALUES (1,‘2019.10.05’, ‘ronaldo’, ‘rua silveira lima’, 985764259, ‘1992.06.14’, 1.75, 75.6),
(2,‘2020.2.05’,‘adriana’,‘rua dr ernestro costa’, 954855523,‘1975.10.11’, 1.63, 65.7),
(3,‘2020.3.24’,‘rafaela’,‘av.Brasil’, 953684759,‘1998.04.01’, 1.55, 55.4),
(1,‘2019.12.07’,‘daniel’,‘24 de maio’, 996587456,‘1994.10.11’, 1.63, 65.3),
(2,‘2018.06.29’,‘rayssa’,‘sao sebastiao’, 996587423,‘2000.05.16’, 1.72, 72.1),
(3,‘2019.04.11’,‘antonio’,‘general silva’, 996584759,‘1963.01.07’, 1.80, 85.7),
(1,‘2019.07.17’,‘fernando’,’ av.recife’, 993586248,‘1983.04.27’, 1.83, 90.4),
(2,‘2019.07.17’,‘maria julia’,’ av.recife’, 996857324,‘1987.11.10’, 1.74, 67.2),
(3,‘2020.01.24’,‘rodolfo’,’ rua varejao’, 975849684,‘1985.08.03’, 1.87, 85.7),
(3,‘2018.05.13’,‘guilherme’,’ rua 23 de marco’, 996363652,‘1998.04.27’, 1.80, 70.8),
(2,‘2018.12.19’,‘arthur’,’ av bernardo vieira’, 997485584,‘1999.08.06’, 1.72, 65.6),
(1,‘2019.06.27’,‘mario’,’ rua macapa’, 996243581,‘1998.03.21’, 1.68, 70.0),
(1,‘2019.01.09’,‘mariana’,’ rua joao fragoso’, 985263478,‘1989.04.13’, 1.70, 80.4),
(2,‘2018.03.24’,‘gabriela’,‘av abdo cabus’, 995135764,‘1999.11.22’, 1.56, 59.7),
(3,‘2020.08.11’,‘barbara’,’ rua professor manoel’, 985236417,‘1975.10.04’, 1.71, 91.5),
(2,‘2020.03.16’,‘raldnei’,’ rua barramares’, 986375142,‘1997.04.11’, 1.77, 67.0),
(3,‘2018.02.01’,‘raysson’,’ av costa e sila’, 998574123,‘1995.11.24’, 1.69, 78.0);
SELECT * from aluno;
#_^__^__^__^__^__^__^__^__^__FIM INSERT ALUNO^__^__^__^__^__^__^_
INSERT INTO turma(idturma, horario, duracao, dataInicio, dataFim)
VALUES (1, '07:30', '2', '2018.02.01','2021.02.1');
INSERT INTO turma( idturma, horario, duracao, dataInicio, dataFim)
VALUES (2, '10:30', '2', '2018.02.01','2021.02.1');
INSERT INTO turma( idturma, horario, duracao, dataInicio, dataFim)
VALUES ( 3, '19:30', '2', '2018.02.01','2021.02.1');
SELECT * FROM turma;
^^^^^^^^^^^^^_ FIM INSERT TURMA ^^^^^^^^^^^^^^
SELECT * FROM matricula;
#^^^^^^^^^^^_ FIM INSERT MATRICULA ^^^^^^^^^^^^^^
INSERT INTO instrutor (rg, nome, nascimento, titulacao)
VALUES(9521250, 'vanderlei', '1971.08.12',2254),
(2587964, 'diego', '1985.06.30',1634);
SELECT * FROM instrutor;
#^^^^^^^^^^^^^ FIM INSERT INSTRUTOR^^^^^^^^^^^^^^
INSERT INTO telefone_instrutor (numero, tipo, instrutor_idinstrutor)
VALUES (998546523, 'TIM',2),
(995362455, 'CLARO',1);
SELECT * FROM telefone_instrutor;
#^^^^^^^^^^^^_ FIM INSERT TELEFONE^^^^^^^^^^^^^^^^
INSERT INTO chamada (dataa, presente)
VALUES (‘2020.01-01’, ‘sim’);
SELECT * FROM chamada;
#^^^^^^^^^^^^^^^^^^^^ fim insert chamada_^^^^^^^^^^_^^
INSERT INTO atividade (nome)
VALUES (‘MUSCULAÇÃO’),
(‘GINASTICA’);
SELECT * FROM atividade;``