sql - How to organize tables to stare statistic of two entities? -


For now I only have two tables

  If there is no existing company ( Id INT faucet primary main entangment, name VARCHAR (250) not faucet; If no employee is present then create table (id INT not primary primary key entangment, name VARCHAR (250), company Iid INT, foreign key (company_id) reference company (ID));   

I need to create one or two tables to store the statistics of employees and companies. For employee statistics, I must remember all the previous employees of this employee and the dates of the reasons The date for renting and congratulating the company's figures will remind me of all the resigners. What is the best way to organize DB structure in my case?

You have multiple relationships, you have a composite table company_employee Is required which combines the primary key, so you need it:

  If there is no existing company (ID INT not original primary key AUTOCCREMENT, do not tap the name VARCHAR (250)) ; If no employee is present then create the table (id INT not the primary key AUTO_INCREMENT, the name VARCHAR (250)); Employee (company_id), foreign key (employee_id), reference worker (id) reference company (idid), key key (company_id) DATE, date of resignation, date of resignation, not vacant, employee_id INT not empty,  < / pre> 

Therefore, if you want something from a consolidated table, then just use JOIN on the key of the appropriate table.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -