I have seen several posts on how to get foreign key references but not the actual relationship type like what is shown in MySQL's workbench ER diagram.
Currently I am using below sql to get references
SELECT
`TABLE_SCHEMA`, -- Foreign key schema
`TABLE_NAME`, -- Foreign key table
`COLUMN_NAME`, -- Foreign key column
`REFERENCED_TABLE_SCHEMA`, -- Origin key schema
`REFERENCED_TABLE_NAME`, -- Origin key table
`REFERENCED_COLUMN_NAME` -- Origin key column
FROM
`INFORMATION_SCHEMA`.`KEY_COLUMN_USAGE` -- Will fail if user don't have privilege
WHERE
`TABLE_SCHEMA` = SCHEMA() -- Detect current schema in USE
AND `REFERENCED_TABLE_NAME` = 'orders'; -- Only tables with foreign keys
What sql do I need to use to let me know if it is a 1:M, M:1, 1:1,
I have read How to determine cardinality of foreign key using mysql which hints at how to find this info.
Does any have an example sql statment to get the relationship type?