Skip to content

Data organization

Cristi Burcă edited this page May 8, 2016 · 6 revisions

Relationship data is stored in two custom database tables.

Current schema:

wp_p2p:
  - p2p_id
  - p2p_from
  - p2p_to
  - p2p_type
wp_p2pmeta:
  - p2p_id
  - meta_id
  - meta_key
  - meta_value

Ancient History

The plugin data organization went through several iterations:

Iteration 1 (custom fields)

P2P 0.1 simply used custom fields to store connections. This turned out to be slow, because the wp_postmeta.meta_value column is defined as longtext, with no index.

Iteration 2 (hidden custom taxonomy)

P2P 0.3 switched to using a hidden taxonomy. This worked reasonably well, even though the queries were pretty strange.

Iteration 3 (custom tables)

In P2P 0.4, two custom tables were introduced: wp_p2p and wp_p2pmeta.

This resulted in simple and efficient queries, as well as the ability to add additional information per connection, using the familiar metadata API.

Iteration 4 (p2p_type column)

In P2P 1.1, an addtional p2p_type column was added to the wp_p2p table, to be able to distinguish between ids of various objects: posts, users etc.