How to connect two tables without a foreign key?

Can someone give a demo?

I use MySQL, but the idea should be the same!

EDIT

Actually, I ask, what is the difference between Doctrine_Relationand Doctrine_Relation_ForeignKeyin doctrine?

+3
source share
4 answers

I suspect you want these to be map columns from one db table to another db table. You can do this using some string comparison algorithm. An algorithm similar to the Levenshtein or Jaro-Winkler distance will allow you to draw conclusions about correspondence columns.

, db1.tableA L_Name, db2.tableB LastName, . , , , , , : "", "" .. .

, ( - !), .

HTH

+2

MySQL, ( - ).

: http://lists.mysql.com/mysql/206589

EDIT: Oracle, - . , .

- , .

, :

CREATE TYPE employee_type AS OBJECT (
      name     VARCHAR2(30),
      manager  REF manager_type 
);

:

CREATE TYPE manager_type AS OBJECT (
      name     VARCHAR2(30),
);

: :

CREATE TABLE employees OF employee_type;
CREATE TABLE managers OF manager_type;

. , :

INSERT INTO employees 
  SELECT employee_type('Bob Jones', REF(m))
    FROM managers m
    WHERE m.name = 'Larry Ellison';

: Oracle

+1

, , . (, Zend_Db_Table PHP), .

MySQL InnoDB, , .

0

- . , SOMEHOW.

( ), , - , ( ) ( , , vs set, , , , )

The absence of a foreign key restriction is not an obstacle to using a foreign key.

0
source

Source: https://habr.com/ru/post/1735827/


All Articles