Implementing one-to-zero-or-one relation in SQL Server

The 1-0..1 relation in your database is directly visible. It is built between Course and OnlineCourse tables where Course is principal in relation (1) and OnlineCourse is dependent with FK configured on CourseID. FK is also PK of the OnlineCourse = it must be unique and because of that it is 0..1. Database “always” uses … Read more

How to find all the relations between all mysql tables?

The better way, programmatically speaking, is gathering data from INFORMATION_SCHEMA.KEY_COLUMN_USAGE table as follows: 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 … Read more