Reputation: 613
I wanted to create table. for example,
create table countryrules(cname varchar(15), rule1, rule2);
here, rule1
and rule2
contain list of strings.
so, please suggest me which datatype i can use?
Upvotes: 1
Views: 10666
Reputation: 23992
I am not sure if you are trying to define a constrained list of values for a column.
If it is true then you can try with enum
or set
of values.
Example:
mysql> CREATE TABLE `set_of_values` (
-> `e` enum('yes','no') DEFAULT 'no',
-> `s` varchar(10) DEFAULT NULL,
-> `e2` enum('ok','ok_2','not_ok') DEFAULT NULL,
-> `e3` enum('ok','ok_2','not_ok') NOT NULL,
-> `st` set('a','b','c') DEFAULT 'c'
-> )
-> ;
Query OK, 0 rows affected (0.45 sec)
mysql>
mysql> desc set_of_values;
+-------+----------------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+----------------------------+------+-----+---------+-------+
| e | enum('yes','no') | YES | | no | |
| s | varchar(10) | YES | | NULL | |
| e2 | enum('ok','ok_2','not_ok') | YES | | NULL | |
| e3 | enum('ok','ok_2','not_ok') | NO | | NULL | |
| st | set('a','b','c') | YES | | c | |
+-------+----------------------------+------+-----+---------+-------+
5 rows in set (0.01 sec)
Upvotes: 1
Reputation: 15871
strings
in a table column.....!!
Mate, this is a database
, it should contain specific values, if you plan to store string
in your schema, i suggest you normalize
your entire database plan from a scratch and then come up with schema to store values in more efficient way!!!!! :)
juergen d's schema is good one to start with!! :D
Upvotes: 1
Reputation: 204746
Instead use another table to relate countries and rules.
country table
-------------
id
name
other_column
rule table
----------
id
name
other_column
countryrules table
------------------
country_id
rule_id
Upvotes: 10