This is more of a backend design question. I'd be using the following 3 tables to populate dropdowns in a web app.
CREATE TABLE request_types(
id INT AUTO_INCREMENT PRIMARY KEY,
name as varchar(32) NOT NULL
);
CREATE TABLE citizenship_types(
id INT AUTO_INCREMENT PRIMARY KEY,
name as varchar(32) NOT NULL
);
CREATE TABLE designation_types(
id INT AUTO_INCREMENT PRIMARY KEY,
name as varchar(32) NOT NULL
);
The design of all 3 is identical, so I'm wondering if it would be a better practice to do something like the following with data of all 3 tables put into a single one and using another to differentiate what group the values belong to.
CREATE TABLE field_types(
id INT AUTO_INCREMENT PRIMARY KEY,
name as varchar(32) NOT NULL,
category TINYINT NOT NULL
)
CREATE TABLE category_types(
id INT AUTO_INCREMENT PRIMARY KEY,
name as varchar(32) NOT NULL
)
where category_types would be populated like so:
{
1:"request",
2:"citizenship",
3:"designation"
}
This is actually not normalized. You can't name any rule of database normalization that would lead you to this design.
One of the normalization rules is that an attribute column must depend only on the key of the table, not on another attribute column. In your design, the name
attribute depends in part on the non-key column category
.
I suggest reading a book like SQL and Relational Theory.