Update Script_Projet.sql

parent 9d283db8
......@@ -91,3 +91,53 @@ CREATE TABLE Posologie(
FOREIGN KEY (idTraitement) REFERENCES Traitement (idTraitement),
FOREIGN KEY (nomMolec) REFERENCES Medicament (nomMolec)
);
/*Methodes*/
/*à tester*/
CREATE FUNCTION naissance (@Naissance date)
returns date
as
begin
declare(@nais date)
set @nais =
case Naissance
when Naissance then Naissance
when NOT(Naissance) then NULL
end--case
return @nais
end;
CREATE FUNCTION espece_autoriser (@Animal string, @nomMolec string)
return (
SELECT CASE WHEN EXISTS (
SELECT *
FROM EspeceMedicament E JOIN Animal A
ON E.nomEspece = A.especeNom
AND A.idAnimal = Animal
WHERE E.nomMolec = nomMolec
)
THEN CAST(1 AS BIT)
ELSE CAST(0 AS BIT)
END -- CASE
)
END;
/* Vues
vPersonne(Union(Projection(Client, nom, prenom, ddn, adresse, numero), Projection(Personnel, nom, prenom, ddn, adresse, numero)))
vPersonnel(Union(Projection(Assistant, nom, prenom, ddn, adresse, numero, specialite), Projection(Veterinaire, nom, prenom, ddn, adresse, numero, specialite)))
*/
/*à tester*/
CREATE VIEW Personne AS
SELECT C.nom, C.prenom, C.ddn, C.adresse, C.numero
FROM Client C
UNION ALL
SELECT P.nom, P.prenom, P.ddn, P.adresse, P.numero
FROM Personnel P;
CREATE VIEW Personnel AS
SELECT A.nom, A.prenom, A.ddn, A.adresse, A.numero, A.specialite
FROM Assistant A
UNION ALL
SELECT V.nom, V.prenom, V.ddn, V.adresse, V.numero, V.specialite
FROM Veterinaire V;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment