You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ensure that all foreign keys are added at the end of table creation using the ALTER TABLE statement. This practice helps avoid conflicts during the table creation process, ensuring smooth schema updates and reducing potential circular dependencies between tables.
Local
Arquivo db_creation.py
Possible Solution
-- Criar as tabelas sem foreign keysCREATETABLEReceita (
Id INTEGERPRIMARY KEY AUTOINCREMENT,
Nome TEXTNOT NULL,
Tempo TEXTNOT NULL,
Instruções TEXTNOT NULL
);
CREATETABLEUtensilio (
Id INTEGERPRIMARY KEY AUTOINCREMENT,
Nome TEXTNOT NULL
);
CREATETABLEValores_Nutricionais (
Id INTEGERPRIMARY KEY AUTOINCREMENT,
Nome TEXTNOT NULL,
Gordura REAL,
Carboidrato REAL,
Proteina REAL,
Porção REAL,
Unidade TEXT
);
CREATETABLECliente (
Id INTEGERPRIMARY KEY AUTOINCREMENT,
Nome TEXTNOT NULL,
Email TEXTNOT NULL
);
CREATETABLEFavoritado (
Id INTEGERPRIMARY KEY AUTOINCREMENT,
Id_Receita INT,
Id_Cliente INT
);
CREATETABLEIngrediente (
Id INTEGERPRIMARY KEY AUTOINCREMENT,
Id_Receita INT,
Id_Val_Nutri INT,
Quantidade REAL,
Unidade TEXT
);
CREATETABLEReceita_Utensilio (
Id INTEGERPRIMARY KEY AUTOINCREMENT,
Id_Receita INT,
Id_Utensilio INT
);
-- Adicionar as foreign keys com ALTER TABLEALTERTABLE Favoritado
ADD CONSTRAINT fk_favoritado_receita
FOREIGN KEY (Id_Receita) REFERENCES Receita(Id);
ALTERTABLE Favoritado
ADD CONSTRAINT fk_favoritado_cliente
FOREIGN KEY (Id_Cliente) REFERENCES Cliente(Id);
ALTERTABLE Ingrediente
ADD CONSTRAINT fk_ingrediente_receita
FOREIGN KEY (Id_Receita) REFERENCES Receita(Id);
ALTERTABLE Ingrediente
ADD CONSTRAINT fk_ingrediente_valores_nutricionais
FOREIGN KEY (Id_Val_Nutri) REFERENCES Valores_Nutricionais(Id);
ALTERTABLE Receita_Utensilio
ADD CONSTRAINT fk_receita_utensilio_receita
FOREIGN KEY (Id_Receita) REFERENCES Receita(Id);
ALTERTABLE Receita_Utensilio
ADD CONSTRAINT fk_receita_utensilio_utensilio
FOREIGN KEY (Id_Utensilio) REFERENCES Utensilio(Id);
The text was updated successfully, but these errors were encountered:
Description
Ensure that all foreign keys are added at the end of table creation using the ALTER TABLE statement. This practice helps avoid conflicts during the table creation process, ensuring smooth schema updates and reducing potential circular dependencies between tables.
Local
Arquivo db_creation.py
Possible Solution
The text was updated successfully, but these errors were encountered: