felito Posted April 22, 2011 Share Posted April 22, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/234452-help-with-database-modeling/ Share on other sites More sharing options...
malinens Posted April 23, 2011 Share Posted April 23, 2011 table job_properties with prop_id, ref, prop_name, prop_value... Quote Link to comment https://forums.phpfreaks.com/topic/234452-help-with-database-modeling/#findComment-1205164 Share on other sites More sharing options...
felito Posted April 23, 2011 Author Share Posted April 23, 2011 thanks. can you be more specific and complete in your answer please? Quote Link to comment https://forums.phpfreaks.com/topic/234452-help-with-database-modeling/#findComment-1205183 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.