https://1drv.ms/u/s!AnKvsQ9OCWw6gatTAp_I5x-gtq-N3g...
Вот примерная схема со всеми словарями.
Ключевое тут то что создаются словари и пара вьюшек.
CREATE VIEW [dbo].[ProfitShareView]
AS
SELECT ps.Id, c.Name, m.LastName + ' ' + m.FirstName + ' ' + m.MiddleName AS Manager, e.LastName + ' ' + e.FirstName AS Employer, a.Name AS Activity, ps.CompanyPercent, ps.ManagerPercent, ps.EmployeerPercent
FROM dbo.ProfitShare AS ps INNER JOIN
dbo.Companies AS c ON c.Id = ps.CompanyId INNER JOIN
dbo.Managers AS m ON m.Id = ps.ManagerId INNER JOIN
dbo.Employees AS e ON e.Id = ps.EmployeeId INNER JOIN
dbo.activities AS a ON a.Id = ps.ActivityId
GO
Продажи
CREATE VIEW [dbo].[TotalSalesView]
AS
SELECT s.Id, s.Name, s.PurchasePrice, s.Price, e.LastName + ' ' + e.FirstName AS emploer, m.LastName + ' ' + m.FirstName AS manager, a.Name AS activity, dbo.Companies.Name AS Company, (s.Price - s.PurchasePrice) * p.EmployeerPercent / 100 AS empRegward, (s.Price - s.PurchasePrice)
* p.ManagerPercent / 100 AS managerRegward, (s.Price - s.PurchasePrice) * p.CompanyPercent / 100 AS companyRegward
FROM dbo.Sales AS s INNER JOIN
dbo.ProfitShare AS p ON s.EmployerId = p.EmployeeId INNER JOIN
dbo.Employees AS e ON s.EmployerId = e.Id INNER JOIN
dbo.Managers AS m ON p.ManagerId = m.Id INNER JOIN
dbo.Activities AS a ON p.ActivityId = a.Id INNER JOIN
dbo.Companies ON p.CompanyId = dbo.Companies.Id
GO