Okay so I am trying to figure out the best design for this problem. I am trying to create a database in which I have leads, clients and contracts. What I am thinking is I should have two tables for the leads and clients. Although these are hopefully the same entities. My second thoughts on this is to just create a table called something like client_status that would look something like.
CREATE TABLE status(
status_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
status_name VARCHAR(40) NOT NULL,
PRIMARY KEY(status_id)
);
INSERT INTO status (status_id, status_name) VALUES ( '1', 'Prospect');
INSERT INTO status (status_id, status_name) VALUES ( '2', 'Client');
CREATE TABLE client(
client_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
fname VARCHAR(40) NOT NULL,
mname VARCHAR(40) NOT NULL,
lname VARCHAR(40) NOT NULL,
PRIMARY KEY(client_id)
);
CREATE TABLE client_status(
status_id INTEGER UNSIGNED NOT NULL,
client_id INTEGER UNSIGNED NOT NULL,
FOREIGN KEY(status_id) REFERENCES status(status_id),
FOREIGN KEY(client_id) REFERENCES clients(client_id)
);
Would this be the correct way to handle the problem at hand?
This is exactly how I would set this up. This allows you to have a
clientwith multiple statuses.The one suggestion that I have is to create the
PRIMARY KEYon theclient_statustable as both columns.