Jump to content

Recommended Posts

I have two tables: one for areas (like science, sport, education), and another for professions (like scientist, designer, golf player). There is a foreign relationship between the two tables, which works without any problems at the moment.

 

But now I need another table to put "number of workers", "average age", "years in the company" (this list is possibly different for each profession). What is the best way to do this? Create another table? What would be the parent? Basically, it is a third statement.

 

CREATE TABLE group (  
    id smallint(5) unsigned NOT NULL auto_increment,  
    area varchar(30),  
    PRIMARY KEY (id) 
)

CREATE TABLE job (  
    ref int(10) unsigned NOT NULL auto_increment,  
    jobid smallint(5) unsigned NOT NULL,  
    job varchar(50),  
    PRIMARY KEY (ref)  
)

    ALTER TABLE job
    ADD CONSTRAINT FK_job
    FOREIGN KEY (jobid) REFERENCES group(id)  
    ON UPDATE CASCADE  
    ON DELETE CASCADE;

 

The point of the question is: for example. A golf player doesn't have a contract with a company (suppose), and a doctor have.

I think this cannot be considered a subcategory of group or job.

 

Any idea?

Link to comment
https://forums.phpfreaks.com/topic/234452-help-with-database-modeling/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.