Reputation: 6217
I've seen this done on multiple occasions, and well, I don't understand it much. Basically, what I do understand is that there is a constraint on the input of these columns, to use both of them as UNIQUE together, but what I don't understand is the purpose of name
? In most cases, the name
field does not even match any columns in the table, so I wonder is it possible to query the database on the name
or something? What is the name used for exactly?
Example:
CREATE TABLE boards (
id_board smallint(5) unsigned NOT NULL auto_increment,
id_cat tinyint(4) unsigned NOT NULL default '0',
child_level tinyint(4) unsigned NOT NULL default '0',
id_parent smallint(5) unsigned NOT NULL default '0',
board_order smallint(5) NOT NULL default '0',
id_last_msg int(10) unsigned NOT NULL default '0',
id_msg_updated int(10) unsigned NOT NULL default '0',
member_groups varchar(255) NOT NULL default '-1,0',
id_profile smallint(5) unsigned NOT NULL default '1',
name varchar(255) NOT NULL default '',
description text NOT NULL,
num_topics mediumint(8) unsigned NOT NULL default '0',
num_posts mediumint(8) unsigned NOT NULL default '0',
count_posts tinyint(4) NOT NULL default '0',
id_theme tinyint(4) unsigned NOT NULL default '0',
override_theme tinyint(4) unsigned NOT NULL default '0',
unapproved_posts smallint(5) NOT NULL default '0',
unapproved_topics smallint(5) NOT NULL default '0',
redirect varchar(255) NOT NULL default '',
deny_member_groups varchar(255) NOT NULL default '',
PRIMARY KEY (id_board),
UNIQUE categories (id_cat, id_board),
KEY id_parent (id_parent),
KEY id_msg_updated (id_msg_updated),
KEY member_groups (member_groups(48))
) ENGINE={$engine};
In here you can see UNIQUE categories
where categories
is the name, but it does not relate to any column name anywhere. Can this be queried or something? Sorry for the Stupid question here. Just never understood this!
Upvotes: 0
Views: 115