Foreign key for binding relationships in field API?

I am using an existing database and migrating to Drupal 7. An outdated database model has a table of basic objects of common columns, and then a type column that determines whether the object is an image, a sample, a taxon, etc. Each "type" has its own separate column table (image table, sample table, locale table, etc.), tied to the table of basic objects using a foreign key.

In some cases, like images, there is a column that refers to the identifier of the sample. In other words, multiple images may belong to the same "instance_id". This identifier is the identifier of the base object of the corresponding instance.

When switching to Drupal, I created a new object for the table of base objects, and then defined packages for each base object of "type". Columns that use part of the type table are now bound to packages during module installation. I do this by defining an array of fields and / or field instances, then iterating over the arrays and calling field_create_field()and field_create_instance().

Is this the right way to do this?
When I create a foreign key field, for example, sampleen_id, how does he know this, refers to the object identifier of the base object for this sample?
To establish these relationships, should I use hook_field_schema()to define them, since it has a foreign key setting, and then creates field and field instances?

Of course, this becomes relevant when creating representations and the need to extract information. I suggest that this could be formulated as a & lt = = bundle connectivity relationship. During CRUD operations, I can get what I need, when I need it, using identifiers.

Any help or understanding is appreciated.

+3
source share
1 answer

Use the Migrate module.

"The migrate module provides a flexible framework for transferring content to Drupal from other sources (for example, when converting a website from another CMS to Drupal).

-1
source

All Articles