
January 30th, 2003, 06:25 AM
|
|
Junior Member
|
|
Join Date: Jul 2002
Posts: 23
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Structure question - which method is better for storing changing fields
Lets say we have a set of tables setup to keep track of what cars a person has but the person can only enter car types that are predefined from a check box:
PHP Code:
CREATE TABLE car (id int(6) NOT NULL default '0',
name varchar(255) NOT NULL default '');
CREATE TABLE user (id int(6) NOT NULL default '0',
name varchar(255) NOT NULL default '');
CREATE TABLE owned (id int(6) NOT NULL default '0',
car_id int(6) NOT NULL default '0',
user_id int(6) NOT NULL default '0');
Would it be better to create it as..
PHP Code:
CREATE TABLE user (id int(6) NOT NULL default '0',
name varchar(255) NOT NULL default '');
CREATE TABLE car (user_id NOT NULL default '0',
$car_name varchar(255) default NULL,
$car_name varchar(255) default NULL,
$car_name varchar(255) default NULL);
.. and add new default NULL fields to the table as more cars are added? I began with the first method, but I'm leaning more twards the second now for simplicity's sake.
What are the reasons that I might want to avoid one method and use the other?
Is there a better method?
Last edited by RyanA : January 30th, 2003 at 06:29 AM.
|