I have successfully linked my MySQL database with my Access database file. Everything is working fine except the relationships in the MySQL database are not appearing in Access.
I have made a plenty of relationships in the MySQL tables using foreign keys, but these relationships are not reflected in Access. Kindly help me to import the relationships from the MySQL database into Access.
Software I'm using: MySQL version 5, Microsoft Office 2013, Access file format: .accdb
While it is true that the MySQL foreign key constraints don't show up by default in the Relationships tab in Access, those constraints are still in place in MySQL and are still enforced for linked tables.
For example, say I have two MySQL tables, [customers] and [orders], with a foreign-key constraint on [orders]. If I link to those tables in Access and I try to insert a row into my [orders] linked table where the [customerID] does not match a [customerID] in my [customers] linked table the insert fails:
ODBC --insert on a linked table 'orders' failed.
[MySQL][ODBC 5.2(w) Driver][mysqld-5.5.29-0ubuntu0.12.04.2]Cannot add or update a child row: a foreign key constraint fails (`zzzTest`,`orders`, CONSTRAINT `orders_ibfk_1` FOREIGN KEY (`customerID`) REFERENCES `customers` (`customerID`)) (#1452)
You can go into the Relationships tab in Access and create "Access-side" relationships for the MySQL tables...
...but notice that the "Enforce Referential Integrity" options are greyed out because that is a function of the database setup at the server, not in Access. So really, the only benefits that the "Access-side" relationships would offer are:
"documentation" of the relationships (which you could get from a database diagram generated against the MySQL database), and
"automatic" joins between the linked tables in the Access query designer (which can also happen without [Access] Relationships if tables have columns with the same name).
It's up to you to decide whether it would be worth the trouble to create those "Access-side" relationships.
Since this is cross databases, it may have to recreated manually.
Check out this one, Importing .sql into MS Access using OBDC
Related
I want to migrate to MySQL from SQL Server. Nevertheless i got some question. In SQL Server there was possibility to create diagram and choose tables which should be shown there. Then using connectors i was anle to connect one table to another by targeting PK field to FK field in another table, morover i could set cascade for update and delete. Is such functionality available also in MySQL?
There was a existing MySQL database. I have reversed engineer the db into MySQL Workbench then created some tables and placed some relationship among tables.
At the end I forward engineered the database. Then I observed the db from phpmyadmin, in that db the new tables and other changes have taken places but foreign keys does not seems to be added. What the problem here???? What should I do?
Foreign keys are only supported by very few table engines. What's yours? Set all your tables to InnoDB and your foreign keys will be kept.
I have a large database structure.
My hosting plan says I can have unlimited databases but each database is limited to 1 GB.
How can I define a foreign key in one database table to reference a table in another database using MySQL and phpMyAdmin?
In the upcoming phpMyAdmin 4.1 (now released as 4.1.0-alpha2), you go to Structure for a table, then Relation view. You then see a panel where you can select other databases for your foreign keys.
In the phpMyAdmin relation view, there is a column for "internal relation" right next tor "foreign key constraint". I know what foreign keys are used for in mySQL, but I've never heard of internal relations.
Is this a phpMyAdmin thing?
This is a phpmyadmin internal mechanism to manage relationship between tables.
This feature is actually useful for MYISAM tables which don't support foreign keys and constraints.
By defining internal relations in phpmyadmin you link tables together which otherwise can't be linked. These information are stored in a phpmyadmin specific table inside your MySQL server (phpmyadmin.PMA_relation).
However this is just a phpmyadmin internal definition and has no effect on mysql itself (no foreign key constraints or referential integrity are enforced).
See here for additional information.
I'm brand new to SQL Server 2008, and have some newbie questions about the diagram pane. I just dragged two tables onto it to do an inner join, and the console "knew" to create a one-to-many relationship between them. Where is this information kept in the Management Studio for me to look at closer?
Thanks!
Much of this information is actually available in system tables in the database containing the user tables.
Here are two of the available tables of interest. sys.tables contains table information, sys.foreign_keys contains relationship information via foreign key constraints.
sys.tables (Transact-SQL) # MSDN
sys.foreign_keys (Transact-SQL) #MSDN
Also handy is the following information on Pinal Dave's site on using this information for your own lookups.
Find tables with Foreign Key Constraint in Database # SQLAuthority.com
Find Relationship of Primary key and Foreign Key using T-SQL # SQLAuthority.com
One of the tables has a foreign key referencing the other table. In Object Explorer, expand the information for the tables involved and look under Keys.