Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I display content for foreign keys in phpmyadmin

Tags:

Whenever I try to insert a new record in my MySQL database using phpMyAdmin, if the column refers to a foreign key, i get a dropdown box with the valid IDs that i can use. The problem is when the database gets too big, the ID is meaningless for me. For example if the ID is the social security number of the employee, i don't know it, but i can probably remember the name. Is there a way to display the row contents next to the ID or at least one column that could be more meaningful to the user? I have seen that feature in phpPgAdmin.

I tried this in the config file:

$cfg['ForeignKeyDropdownOrder'] = array( 'content-id', 'id-content' ); 

But it didn't work.

like image 971
Tales Avatar asked Dec 31 '12 17:12

Tales


People also ask

How do I display foreign keys in phpMyAdmin?

To see FKs of a table first select table from the object explorer, then go to Structure tab and then select Relation view. Please note that in different versions it might be in different locations. On the Relation view screen you will see all foreign keys defined for this table (as a foreign table).

How do I display data in phpMyAdmin?

When you open the phpMyAdmin home page, click on Databases and then select a database to manage by clicking its name. In the page that opens you will see a list with the database tables, the allowed actions with them, the number of the records, the storage engine, the collation, the tables' sizes, and the overhead.

How do you display foreign key names?

To see foreign key relationships of a table: SELECT TABLE_NAME, COLUMN_NAME, CONSTRAINT_NAME, REFERENCED_TABLE_NAME, REFERENCED_COLUMN_NAME FROM INFORMATION_SCHEMA. KEY_COLUMN_USAGE WHERE REFERENCED_TABLE_SCHEMA = 'db_name' AND REFERENCED_TABLE_NAME = 'table_name';


2 Answers

phpMyAdmin has a function for this, but you must be using the InnoDB table type. You must also have pmadb configured.

  1. Select the table that contains the foreign key (child).
  2. Click the "Structure" tab.
  3. Click "Relation view".
  4. Under the foreign key constraints, click the "Choose column to display" drop down and make a choice.

The column value will now be shown next to the id. It will also be shown when hovering over the foreign key value after making a selection.

For anyone having trouble getting this setup, please see the #relation-view documentation which tells you exactly how to configure it with screenshots.

like image 128
EternalHour Avatar answered Oct 03 '22 00:10

EternalHour


In addition to what @EternalHour says you also need to check the radio button under view options enter image description here

that says "Relational display column" if you want the value to be displayed.

enter image description here

If not checked you will only see the Foreign Key value when you hover that specific id.

like image 34
iontomet Avatar answered Oct 03 '22 00:10

iontomet