Jump to content

Foreign Key explination


synking

Recommended Posts

Hey everyone.  Thought i would ask on here cuz i don't seem to be understanding it.

 

I am trying to setup a system where people input ideas to improve a project.  Each idea is supposed to go through certain stages of approval or denial.  I have one table that store all the ideas.  which looks like

DESCRIBE ideas;
+----------+--------------+------+-----+---------+----------------+
| Field    | Type         | Null | Key | Default | Extra          |
+----------+--------------+------+-----+---------+----------------+
| Id       | int(5)       | NO   | PRI | NULL    | auto_increment |
| Date     | date         | NO   |     | NULL    |                |
| Email    | varchar(255) | NO   |     | NULL    |                |
| Name     | text         | YES  |     | NULL    |                |
| Headline | text         | YES  |     | NULL    |                |
| Problem  | text         | YES  |     | NULL    |                |
| Promise  | text         | YES  |     | NULL    |                |
| Proof    | text         | YES  |     | NULL    |                |
| Threats  | text         | YES  |     | NULL    |                |
| Passion  | text         | YES  |     | NULL    |                |
| Cost     | text         | YES  |     | NULL    |                |
| Value    | text         | YES  |     | NULL    |                |
| Purpose  | text         | YES  |     | NULL    |                |
+----------+--------------+------+-----+---------+----------------+
13 rows in set (0.01 sec)

 

Which i am trying to assign a foreign key too so that the status of them can be related to a seperate table.  But my issue is im not sure if that is the best way to do it... Should i just add another column to this table for the status and not worry about creating a second table.  If i do create a second table what is the best way to handle the foreign key relationship.

 

Just trying to get ideas thanks guys

Link to comment
https://forums.phpfreaks.com/topic/268067-foreign-key-explination/
Share on other sites

I'd probably just add another column myself... But 'status' for me is usually limited to 'Complete', 'In Progress', or 'Not Started'

 

It really depends on how flexible you need to be with your status. Generally, if you only have a few different options it's not worth it to move over to a foreign key.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.