Ads were blocked - no problem. But keep in mind that developing HeidiSQL, user support and hosting takes time and money. You may want to send a donation instead.

Display of foreign keys different when viewing or editing

mongoose34's profile image mongoose34 posted 4 weeks ago in Feature discussion Permalink

If I'm editing a field that contains a foreign key, the drop-down menu that I can choose from shows me both the valid values for the foreign key and some text from another field in the table, e.g. "17 (John Smith)". This is great, and makes selecting a foreign key really easy.

But when viewing the table with the foreign key, it just shows the key, e.g. "17". Is it be possible to display the same text that appears in the drop-down menu for editing, e.g. "17 (John Smith)"?

ansgar's profile image ansgar posted 4 weeks ago Permalink

But when viewing the table with the foreign key, it just shows the key, e.g. "17".

That sounds as if you disabled the other column(s).

Please post a screenshot and/or CREATE TABLE code.

mongoose34's profile image mongoose34 posted 4 weeks ago Permalink
`CREATE TABLE `people` (`
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `country` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
)
CREATE TABLE `test` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `person` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `FK__people` (`person`),
  CONSTRAINT `FK__people` FOREIGN KEY (`person`) REFERENCES `people` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
)

When editing the 'person' column in 'test', I get a dropdown menu that shows not only the actual foreign key value ('people.id'), but it also shows the corresponding 'people.name' value, which makes editing really easy.

But when viewing 'test', the 'person' column only shows the 'id'. Can it display the foreign key in the same format as the dropdown menu for editing, and show both 'id' and 'name'?

2 attachment(s):
  • edit
  • view
ansgar's profile image ansgar posted 4 weeks ago Permalink

Ah you mean the difference between editing and viewing. Ok, the idea does not sound too bad. Only that would require the SELECT query for the data grid to join all the tables to which it has a foreign key. That would result in a bad performing data grid on larger tables, so I cannot recommend that.

Please login to leave a reply, or register at first.




Ads were blocked - no problem. But keep in mind that developing HeidiSQL, user support and hosting takes time and money. You may want to send a donation instead.