Bonjour,
dans le cadre d'un cours de business intelligence , nous sommes censés coder le passage d'un schéma relationnel à un schéma en étoile contenant une fact table et des dimensions (telles que produit, endroit,..).
La base de données s'inspire fortement de l'exemple trouvé ici: https://technet.microsoft.com/en-us/...=sql.100).aspx
Je rencontre actuellement un problème lorsque je lance cette dernière requête: 1066 not unique value/table sur la dimension produit.
Je voudrais donc passer de ça:
(ERD)
à ça (Star Schema)
, en organisant un star schema autour de workorder.
Or la dernière partie de mon code m'indique que la table 'dimension produit' n'est pas unique.
Par ailleurs, j'aimerais pouvoir encoder la dimension temps, ce qui me pose également quelques problèmes.
Voilà, merci d'avance aux courageux qui voudront bien aider un apprenti en SQL,
Bonne soirée
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 Create table if not exists workorderFT( WorkOrderID INT, ProductID INT, LocationID INT, StartDate datetime, EndDAte datetime, DueDate datetime, BillOfMaterialsID INT, primary key (WorkOrderID), foreign key(DimProduct_Key, LocationDIM_Key, StartDate, EndDate, DueDate, BOMDIM_Key,Time_Key) references workorder(WorkOrderID) ) AS ( SELECT DISTINCT workorder.WorkOrderID,`workorder`.StartDate,`workorder`.EndDate, workorder.DueDate, workorder.ProductID, location.LocationID as LocationID, billofmaterials.BillOfMaterialsID as BillOfMaterialsID FROM workorder, Location_DIM, BillOfMaterials_DIM, Product_DIM right Join Product_DIM ON (workorder.ProductID = Product_DIM.DimProductKey) left JOIN location ON (workorder.LocationID=location.LocationID) JOIN billofmaterials ON (workorder.BillOfMaterialsID=billofmaterials.BillOfMaterialsID) );
Partager