Question

Im creating a database design in MySQL Workbench. I want to have a enumarated table which holds some standard values. The values of the enumaration table needs to be linked to a row in my other table. So i have a table called 'club' which holds a row 'club_soort'. The row 'club_soort' needs to relate to the enumaration table.

Also, I want to use my tables (when i'm ready with my database design) into phpMyAdmin.

I understand the concept of enumaration, but I can't implement it. I hope someone can help me! Thanks!

Was it helpful?

Solution

Rather than using enumerations, you should use what's known as a lookup or reference table. This table would contain your enumerations and be referenced as a foreign key by the parent table.

As an example, this would look like:

parent_table
------------                club
id                          ----
club_soort    ---------->   soort

OTHER TIPS

ENUM values cannot be linked to any MySQL structures. It can contain only static data.

Are you talking about primary keys?
Being a relational database, mysql uses primary keys and indexes to joint data the way you want to achieve.
Primary keys join tables in an efficient way, PK in the the origin or parent table and FPK, Foreign Primary Key in the related table.
When creating a table, in mysql workbench or phpmyadmin, define a primary key, just one per table and if needed indexes and if needed foreign keys.
Use union statements to join two or more tables.
Always use numeric keys data_type INT instead of natural, string keys. Also make then autoincrement and Not Null.
mysqlworkbench has an exporting tool, which allows you to export each created table, including their keys, indexes and cascading. You can copy and paste to create tables in phpmyadmin.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top