0

I have 3 models/tables as described

holding

An individual financial holding for a portfolio at a point in time. The fields here are id, date, sedol_id, value


sedol

A table with sedol-specific data.


asset

More general data about an asset. Several sedols can refer to the same asset, but a sedol only refers to one asset.

Here is an overview of the linking:

tables

I'm struggling to associate the models in the Cake. Which model hasOne, hasMany or belongsTo the other. I have tried many combinations but either get a memory exhausted error (infinate loop?) or an SQL error where the joining is not done correctly.

Here's an example in case my question isn't clear.

Let's say there's a holding records which is shares in Vodafone PLC. this might appear in the holdings table like

     id   | sedol  |   date     | value
   ---------------------------------------
   123456 | 16GWD5 | 2013-09-15 | 15456.25

Now this holding's sedol refers to the Sedol table which has share-specific info. Among this info in the SEDOL table is an ips_asset_id which refers to the company itself. E.g. Vodafone may have several different classes of shares (represented by sedols) but the fundementals of the company equity would be in the ips_assets table.


EDIT: OK I think I have solved the joins but when I query the database to find all the sedols it tries to retreive every holding, when all I want to do is get the data from the holdings table. Any ideas?

4

1 回答 1

0

在您的示例中:

  • Holding belongsTo Sedol
  • Sedol belongsTo IpsAsset

但是,我对您的模型知之甚少,无法知道另一种方式的关系是否是 ahasOnehasMany

于 2013-09-25T16:17:00.703 回答