Relationship issue in the MySql designer - mysql

Normally I have no issue with MySQL's PHPmyadmin designer to create referential integrity relations.
All of a sudden, I now get a 99% Loading in my browser window, and a popup php.
Reproduce;
Select a database.
Select designer.
Select 'Set Relation'
Select a primary key
Select a coresponding foriegn key
Approve confirmation
Expected results; (and what I usually get)
A relationship is setup.
A line connecting two keys.
Actual results;
a green label "Loading 99%" appears in upper right corner.
a second window pops up http://localhost/phpmyadmin/pmd_general.php?db=jobhunt&server=1&token=d8235.....
Relationship does not occur.
Is anyone else getting this?

Yep, it was happening with me too. I've made some attempts here and discovered that the error of the blank pop-up occurs because I was trying to make a relationship with a foreign key that has no index set up.
Create an index for the future foreign key column and that may resolve.
Pay attention that when you try to make the relation without the index, the confirm box that appears has just a "Ok" and "Cancel" button, while when you already have the index, it permits you to set up the behaviors on delete and on update.

[Solved] Just update Java for Windows plugin for your browser (Firefox, Chrome...)
Go to Java site and update Java Firefox plugin.
One more solution is install and use SQLyog;

While I still do not know why the interface decided to break but an add Forien Key works fine.
ALTER TABLE tableblah
add FOREIGN KEY FCK2-BLAH ([Foreign-Key column]) REFERENCES [primary key table]([primary key column]);

This method works for me:
1. Select table and click on Operations.
2. Change Storage Engine in table option to InnoDB.
3. Hit "Go" button.
Now, you can add foreign key by adding INDEX on column.

Related

Phpmyadmin version 4: Relation view sometimes does not show foreign key constraints

I have a database that I built a while back. Every table in the database is InnoDb. Several tables had foreign key constraints, and I set them up for On Delete = Cascade. When I was using an earlier version of phpmyadmin, working with these was simple: I'd just go to the Structure tab of a table, click the Relation View link, and as long as I had the correct indexes set up on the correct columns, I could set the foreign keys as I saw fit.
Since upgrading to version 4, it's become a nightmare. For some tables, I go to the relation view and everything is just fine. But for others--even when they already have foreign key constraints set--I can't see any options for working with them.
To make matters worse, I've even tried dropping the indexes and re-adding them, only to be given the following error: Cannot drop index [index_name]: needed in a foreign key constraint. So unless I'm mistaken, the constraint is there, but phpmyadmin is refusing to show it to me.
Is there something I have to do to make them show up again? This is extremely frustrating to say the least: something that worked just fine before now does not thanks to an upgrade.
OK, after playing around with the tables a bit, I figured out what's going on. The only time the foreign key constraint options don't show up are when the table names contain capital letters. Very frustrating to say the least.
I just filed a bug report for phpmyadmin: https://github.com/phpmyadmin/phpmyadmin/issues/11461
It should be an easy fix.
happened to me because i used '&" in the database name.
In my case it is that I used two columns (A and B) both as foreigns keys to other tables then I also used a composite unique for ([A, B]), phpMyAdmin does not show the existed foreign index of column A but does show that for column B.
My system version are as follows:
Server version: 5.7.30 - MySQL Community Server (GPL)

MySQL Workbench, dropping foreign keys

(Caveat: I am not a MySQL pro, I use Workbench in lieu of knowing commands, so my question is likely an easy one)
I'm trying to rename a primary key (userID) in a table (user), but MySQL won't let me (errno 150). After some digging, it appears that I must first drop foreign keys before renaming my primary key.
So, in Workbench, I go to the next table (question) and choose alter table, then go the the Foreign Keys tab. I select the only foreign key in the left window (fk_Question_user), uncheck the only checkbox in the middle window (userID), then hit Apply. Workbench gives error 1050 "table 'question' already exists" (of course it already exists, I'm trying to edit it). Anyway, any help is greatly appreciated.
On the SQL Queries preferences page you can enable the data change wizard which shows you what will be sent to the server for review (Confirm Data Changes).
With that enable you should see what MySQL Workbench sends to the server. It should not do a CREATE TABLE however.
I figured it out. Rather than unchecking the field in the center pane of the foreign keys tab, the correct way to do this is to select the foreign key in the left-hand pane then select delete from its contextual menu and apply.

Issue with multiple cascade paths

I have designed an diagram in sql server 2008.
as you can see in the photo:
Now in Value table I set the cascading delete ON for Feature and ProductDetail but I see the error below:
'Feature' table saved successfully 'ProductDetail' table saved
successfully 'Value' table
- Unable to create relationship 'ValueFeature'. Introducing FOREIGN KEY constraint 'ValueFeature' on table 'Value' may cause cycles or
multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO
ACTION, or modify other FOREIGN KEY constraints. Could not create
constraint. See previous errors.
What is it wrong with my design?
I think I have faced the same problem some years ago, in SQL server 2005. I suppose that nothing is wrong with your design. If you delete a Feature you want all the Value records to be deleted. Nothing wrong with that. If you don't have other cascades, the automatic delete will not propagate further. However, it seems that SQL Server is not clever enough to understand that, and does not allow you to have such a relationship, just because you have foreign keys that form a circle. I think that if you remove a foreign key (just for testing) and break the circle (for example delete the FK between the ProductDetail and Product) there would be no error.
Check this stackoverflow question too..
Hope I helped!

Cayenne "resets" primary key value?

I am using Cayenne to add records to a MySQL database, and I am seeing some strange behavior.
When I run my application, I create a DataContext, perform a series of adds, then close the application. This works out well, because I am using an integer for a primary key, and when I add a record to the database, the key automatically increments. For some reason, it starts at 200 for the first record, then goes to 201 for the second record, etc.
If, however, I stop the application, then run it again, the primary key starts at 200 again! This, of course, causes an exception to be thrown because a new record ends up having a duplicate primary key. It is looking like when I create a new object using the DataContext's newObject() after starting my application, Cayenne does not "remember" how far the primary key was incremented when the application was previously run.
Does anyone know what is causing this reset of the primary key values, and (more importantly) how to stop it from happening??? Or have I found a bug in the current version of Cayenne? I am using Version 3.0.2.
Someone please advise...
The last used PK for a given table is stored in a special table called AUTO_PK_SUPPORT. Please check the contents of this table between the restarts of your app. Also check you application Cayenne logs for reads and writes to AUTO_PK_SUPPORT. This should give you an idea of what's happening.
Aside from that you might switch to auto-increment PK (see "Primary Key Provided by Database" section here). MySQL supports auto-incremented PK columns and if you have an option of altering the schema, this IMO is the cleanest PK generation strategy out of all available. (And it doesn't require AUTO_PK_SUPPORT).

problem with index -mysql workbench

The relation of PRIMARY is equal to fk_student_single_user1. So i must remove one of them.
The problem is, i can't remove or rename PRIMARY in workbench, the program does not allow, and if i delete fk_student_single_user1, i also delete the foreign key. The only way is delete PRIMARY in the phpmyadmin.
But i think that exists any problem in my eer model, it is supposed an export without bugs.
I deleted my previous column id, because two foreign keys can be the primary key of the table.
How i can solve that?
Try deleting the foreign key, dropping the needless fkey index, and re-adding the foreign key using plain sql (alter table...) rather than your GUI.
The SQL spec requires a unique index on the target column, so there's no reason to add an extra (non-unique) index on top.
If MySQL still adds the index, you might want to report it as a bug (as well as to http://sql-info.de/mysql/gotchas.html).
If not, you might want to investigate whether the index was added by your GUI in the first place. And if so, report the issue as a bug to the GUI's creator.