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?
Related
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 MySQL, using MySQL Workbench, how can you create a foreign key relationship to a table which resides in another database? After entering the 'Qualified Table Name', of DatabaseName.TableName.ColumnName, workbench simply acts like I put nothing in the box. Do I need to create these relationships only with manual query in workbench if it is a different database?
InnoDB engine allows you to define FK(Foreign Key) for tables.(even from other databases)
For this you must mention database name before table and column name. Like so :
dbname.tablename.columnname
I think I found the solution. Actually you have to add another schema in your Model which represents your 'different' database.
Then you need to create all your tables (in an EER Diagram) into this new Schema.
Finally, when you'll click on the Foreign Keys tab from the original table you'll be able to choose the right table from the different database in Referenced Table. For example different.new_table
I think it is impossible to do what you want. You can not link tables from different databases.
I'm trying to create some meta-data to extend mysql functionality but I can't create tables in the database INFORMATION_SCHEMA. I thought that I could just create another database and have my metadata in there but I need some foreign keys from my tables to some tables in the INFORMATION_SCHEMA DB. Nevertheless, I get errors when trying to create them. Then I thought I could create a trigger to get notified of changes but since triggers are associated to a table and I can't alter that database, I can't create triggers either.
Specifically I have some tables that references to information_schema.schemata(schema_name) and to information_schema.schemata(columns) and some others. I want to have those foreign key so I can use ON UPDATE CASCADE ON DELETE CASCADE or otherwise I'll have some rows in my tables referencing to nothing and I can't allow that.
I'm using mariaDB 5.5.30 which uses MySql 5.3.
INFORMATION_SCHEMA tables are actually views whose contents is automatically maintained by the MySQL server.
The manual gives more information:
Inside INFORMATION_SCHEMA there are several read-only tables. They
are actually views, not base tables, so there are no files associated
with them, and you cannot set triggers on them. Also, there is no
database directory with that name.
Although you can select INFORMATION_SCHEMA as the default database
with a USE statement, you can only read the contents of tables, not
perform INSERT, UPDATE, or DELETE operations on them.
They are not really views but temporary tables, that's why you don't see folders.
show create view views;
ERROR 1347 (HY000): 'information_schema./tmp/#sql_2ac_0' is not VIEW
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
In SQL Server 2008 I had remade the database structure similar to Access. I need to import a couple of related tables but I am worried that the foreign keys won't match with the autonumber fields from the related tables.
You have some options here:
If you export the table to SQL Server, all the data will make it through properly and then you can set your PKs and FKs
Create the Table structure with an IDENTITY column and use SET IDENTITY_INSERT to put in the values you want into the Identity column.
Without knowing more details about your table structures and locations, I can only tell you generic things like
You will have to match the keys up manually so that the PK-FK references remain the same.
If you need to match the old access ids to the new autogenerated ids in an existing table, this is something you needed to do at the time of moving the data from the orginal table unless you happened to store the access ids. Usually I do some type of a cross matching table with the old id and the new id as part of the import process. Then you use this table to match to the realted tables to update their ids. If you didn;t do this and the ids are differnt, you will have to find a way to match them to the orginal access table first before you can import the related tables. I hope your table has a natural key in that case.
If the tables are the same you could use the rather verbosely named “Microsoft SQL server Migration Assistant 2008 for Access”. This will allow you to bring over the data whilst keeping the same keys