We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
SELECT c.Company_Code, c.founder, count(Distinct e.Lead_Manager_Code), count(distinct e.Senior_Manager_Code), count(distinct e.Manager_Code), count(distinct e.employee_Code) FROM Company c JOIN Employee e ON c.Company_Code = e.Company_Code GROUP BY c.Company_Code, c.Founder ORDER BY c.COMpany_Code;
only has one join, Company to Employee. Make it simple coz Employee has All Codes from previous tables (Manager_Code, Senior_Manager_Code, Lead_Manager_Code, and even Company_Code).
Is this proper schema for building database? (normally i would build Employee table only have one foreign key to Manager_Code)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
New Companies
You are viewing a single comment's thread. Return to all comments →
using SQL:
SELECT c.Company_Code, c.founder, count(Distinct e.Lead_Manager_Code), count(distinct e.Senior_Manager_Code), count(distinct e.Manager_Code), count(distinct e.employee_Code) FROM Company c JOIN Employee e ON c.Company_Code = e.Company_Code GROUP BY c.Company_Code, c.Founder ORDER BY c.COMpany_Code;
only has one join, Company to Employee. Make it simple coz Employee has All Codes from previous tables (Manager_Code, Senior_Manager_Code, Lead_Manager_Code, and even Company_Code). Is this proper schema for building database? (normally i would build Employee table only have one foreign key to Manager_Code)