sql server - If one table (A) relates to another (B), which relates to another (C), can I write a query to get table out of A from a join between B and C? -
i have 3-table schema. 2 of tables (trade/portfolio) have 1:1 relationship, fk on 1 of these tables has unique constraint.
the table, explained above, fk (which portfolio) relates third table. third table (price) displaying historical information portfolio (there can many prices portfolio on time-period), there's bog-standard 1:m relationship.
however, need various prices portfolio. that's easy query works on portfolio id. however, feasible way price of single trade? there limitation in design prevent this?
apologies long title, not find better way explain issue!
thanks
by description guess data model. fk tradeid unique in portfolio.
and wonder if possible rows price related trade. here query give rows price tradeid 1.
select price.* portfolio inner join price on portfolio.portfolioid = price.portfolioid portfolio.tradeid = 1
i see nothing in design prevent fetching rows price given tradeid.
Comments
Post a Comment