How to add relation between two tables in Mysql using Mysql control center - mysql

I want to create two tables with one to many relations. I use MySql Control center,but I did not find to add foreign key.I do not want to use console commands,How can I do? I also want to use transation so I use InnoDB table type, How can I add relation between two tables in Control Center.Is there another GUI software to handle Mysql?Pls tell me.

You should check SQLYog by Webyog
http://www.webyog.com/en/downloads.php#sqlyog

Why don't you give a try to MySQL Workbench 5.1 OSS it can do the job for, after created the entity you just export it as SQL format or XML as you wish, then import to your mysql database.
Folow the link Download Here

Related

MySQL Workbench Data Export Select Tables

I am using the Data Export functionality to create a dump of a database in MySQL Workbench. Once I select the database, I want to select a subset of the tables on the right side in the screenshot. However, the list of tables is not displayed. How do I make a single-file dump of a subset of tables of a database?
Click on one row and you see the tables
It may sound dumb from me, but have you tried to click on the database choosen, not just check it.
Try to click the name of the database.

Is there any way join tables of MySql and PostgreSQL?

I have a table in MySql in one server and a table in PostgreSQL in another server.
I want use use JOIN operation with those tables.
Is there any way to join the columns?
If not, is there any way to print the rows in same order?
Please help!!
Use mysql_fdw to define the MySQL table as a foreign table in PostgreSQL. Then you can join it with the PostgreSQL table in PostgreSQL.
You can use Materialize to achieve this.
Here is a sample demo project that you can run to see this in action:
You can find the code for the demo project and how to run it on GitHub here:
https://github.com/bobbyiliev/materialize-tutorials/tree/main/mz-join-mysql-and-postgresql
Hope this reference helps.
Yes, it is possible to work with multiple databases at the same time but you're looking in the wrong place. psycopg2 is just a library that simplifies accessing and manipulating data coming out of PostgreSQL but it doesn't go far beyond what you can do with psql. What you're looking to do you can solve on the database level by using Foreign Data Wrappers.
This does become more complicated in your schema definition but brings remote tables from host some.other.server database remote_db to appear as though they live on localhost in database local_db....
More:
https://dba.stackexchange.com/a/120682/197899

Mysql workbench not showing realtions after reverse engineering database

I'm using MySQL workbench 5.2.35 CE to reverse a Mysql Database and show the diagram of tables with their relationships.
I am able to get every table and its fields but the relations between them is not shown. Why is that? Is there any way it can be fixed?
Most often, the relations between tables are not stored in the DB. How to combine two tables is entirely up to the SQL query and because there are near endless possibilities to name your columns this is not easy to guess. Try to find some SELECT statements or use brute force to find out wich columns match.
If you are using MyISAM as the database engine, your database is not fully relational. Make your database fully relational by using InnoDB engine. Then you will be able to see the relations when you do reverse engineering. But please note that each has pros and cons of its own. Google MyISAM vs InnoDB to find out more about the differences.
I have tested mysql-workbench for both 5.2 and 6.0 latest version. My database got foreign key constraints defined clearly. My database is using mysql-native SQL. But the relationships are shown as line between tables. I have created another test database with only two tables. In this case the InoDb was used as engine. The foreign key constrain clearly defined. Still it only generate two lonely table object in the ER diagram after going through the "reverse engineering" module.
While using another commercial software, I was able to generate the 'lines' between the Entities.
My question is, is this a problem of workbench itself, or some error on my part. My database server is the latest stable version 5.6.12. If I can get an answer, this will be good for everyone. You don't have to waste time trying to get an ER-diagram with this piece of software.

Determining dependent tables in MySQL?

In MySQL, I need to know which tables depend on other tables. Is it possible to get the relations?
In SQL Server it's possible to see dependent tables. I hope MySQL can do this too.
If it's in pictorical form then that's even better.
Perhaps you want the SHOW CREATE TABLE command?
If there are foreign keys defined, the above command will show you what they are.
Take a look at the information_schema, especially to key_column_usage table.
http://dev.mysql.com/doc/refman/5.0/en/key-column-usage-table.html
Have a look at Database Explorer (object dependency tree) - a unique feature in dbForge Studio for MySQL.
Easily explore object's references and dependants in Database Explorer. Compilation of dependants for debugging is now also available through the object's context menu.
Also, Database Designer can show foreign key relations between tables.
maybe you'd want a graphical front-end to mysql since you're so used to SQL Server. if the foreign keys are defined, it will show up as a link between entities when you reverse engineer the database.

Tables from two different databases in a DBML?

After dragging two tables in from one database, I switch to another and drag a table in. Now I get a message if I want to replace the connection string with the new one. I want tables from multiple databases in one DBML. Is this possible?
It is entirely possible to reference multiple databases within the same DBML, PROVIDED those databases reside on the same SQL Server.
In Visual Studio, right-click on the DBML, click "Open with..." , and select XML (Text) Editor with Encoding.
You will see your first table that you dragged in looks like this:
<Table Name="dbo.MyTable1fromMyDatabase1" Member="MyTable1fromMyDatabase1">
For your tables from other databases you wish to add, enter them like this:
<Table Name="MyDatabase2.dbo.MyTable1fromMyDatabase2" Member="MyTable1fromMyDatabase2">
This will work assuming the same login works for both databases, and your LINQ expressions can now query across both databases!
I don't believe that what you're looking for is possible, since the DataContext would then not have any easy way of resolving results from two separate databases.
If you're looking to create domain objects from two separate databases, then your best bet would be to have two separate DBML's, then use a bridge (GOF) or some other related design pattern to instantiate your domain objects.
Another option is to create a server link on on database that points to the other and make aliases to the remote tables from the "local" DB. I believe then you'd be able to reference them as if they were all in the same database.
We can also create a view that queries the table in the other database. We can select, insert and update this view, which will affect the table in the other database as well.