SSAS: why aren't FK relationships shown with named query? - visual-studio

I have two fact tables: FactSales & FactInvoices. Both have an foreign key relationship with DimDate.Datekey. In VS, the SSAS DSV displays these relationships (the lines are drawn between the tables).
In the DSV I decided to to create a named query that limits the dimdate to 2021. After doing this, I still see the relationships between the two fact tables and dimdate (which is now a named query).
At the DB-level, I created a 3rd fact table called FactExpenses. FactExpenses also has an FK relationship with DimDate.Datekey. The problem is that my dsv (in SSAS) does not recognize this relationship (ie. It doesn't draw the line between both tables).
Two questions: why doesn't VS display the relationship between my 3rd fact table with the named query but it does with the other two fact tables? I understand that the relationship isn't with the named query, but the relationship should disappear in all the fact tables.
When I want to limit the amount of data displayed in dimdate, should I use a named query?

The relationships in the DSV are separate to the foreign keys on the base tables, but they get added automatically based on the database schema when you add tables to the DSV. My guess would be when you added the initial dim and fact tables to the DSV in Visual Studio it automatically added the relationships based on the foreign keys that exist on the base tables, but this may not occur automatically for named queries. You can manually add the relationship yourself for the third table to get the same result.
I think a named query is a reasonable approach for the filtering you want to do. An alternative would be to create a view in the source database if you need to do more intense or complex filtering.

Related

Oracle Data Modeller: Recursive One to many relationship

I am having trouble understanding how to create recursive one to many relationships in a logical model built by Oracle data modeller.
The relational relationship should be similar to this i.e Manager ID is a FK for the same table
I have my logical model set up as so:
However, when I engineer to relational this is my result.
This behaves fine if I am creating a relationship for two different tables, Manager and Employee. PK on source table appears as FK target table.
How can I set up my logical model to create one FK called managerID with a one-to-many relationship on the same table?
Thanks.
i faced it initially.I think you have done the steps correctly, its just the notation is not showing the linkage as i see the linkage in the diagram but the attribute is not visible in the diagram.Try switching from Barker notation.
go to View>>Logical Diagram Notation >>Information Engineering Notation
let me know if this resolved your mystery :)

Laravel Eloquent : two keys relationship

I have a first table named "Building", and this one gets a Type and a Level. There are multiple building with same type and level.
I have another table named "BuildingInfo", who also gets a Type and a Level. The couple Type/Level is unique on this table.
Is there a way to have a HasOne relationship on Building, giving me the matching BuildingInfo ? The problem being that there are two keys on each table to get it, and I can only specify one key for each table with HasOne().
Thank you.

GAS ORM many-many relation with attributes

I'm using CodeIgniter and I'm starting to work with gas orm.
One of my m-n-relationship-tables using a composite key has also some additional attributes to the releation.
For Example:
Table teams, Table employees, and a m-n table which binds them together + adding the attribute role
Is it possible to get the attribute using GAS ORM?
Yes, it is possible.
Simply create a new relationship in one of the two tables you are going to link with the pivot table that refers to the pivot table itself as a has_many relation. (But dont do the linking stuff in the model file, eg:
ORM::has_many('\\Model\\User\\Role')
instead of
ORM::has_many('\\Model\\User\\Role => \\Model\\Role')
See http://ellislab.com/forums/viewreply/1050559/ for exact the same question.

Unable to add a table from an existing database to EDMX using Database First Entity Framework

I am using Database First EF to generate model from the existing database. When I first generated the models, it ignores only one of the table, the entity was not added to EDMX, no model file is created for the table and no context is created for the entity.
When I tried to explicitly add the table to EDMX (when generating the model, selected the specific table first and then updated the model with all the other tables from the database), it complained with the following error.
Two entities with possibly different keys are mapped to the same row. Ensure these two mapping fragments map both ends of the AssociationSet to the corresponding columns.
This specific table has two columns which are primary keys of some other tables and both the columns are specified as Primary keys for the table.
Am I doing something wrong or should I handle this table differently since it has two columns defined as Primary Keys? Any suggestions greatly appreciated!
You are not doing anything wrong. Your table is junction table for many-to-many relation. You don't need that table in the model because EF (in contrast to database) can handle many-to-many relation directly without any intermediate. The table is actually mapped on behind of the many-to-many relation - you will see that in mapping details window.
Btw. you are not using code first. Code first = no EDMX.

Entity Framework, odata syntax

As indicated in the Entity Framework image below, I have 3 tables, tblModel, tblModelFetish and tblFetish. A record in tblModel can have multiple records in the tblModelFetish table linked by the modelid column. The tblModelFetish table links to the tblFetish table via the fetishID column to get the fetish description stored in the fetish column. This Entity Model was generated with VS 2010 from an existing database including foreign keys.
a Entity Data Model http://spreadthenudes.com/efmodel.jpg
Using the odata syntax, I'm able to access all models (http://localhost:51157/WcfDataService.svc/tblModels) or a specific model (http://localhost:51157/WcfDataService.svc/tblModels(11)) successfully. I'm having trouble accessing the related tables data via odata, I've tried many permutations including expand etc.
What I want is a result set of all the columns in the tblModel and the related tblFetish records including the fetish column from the tblFetish table. In other words, Mary (a modelname in tableModel) has 3 fetishes (3 records in tblModelFetish) named beach, travel and coffee (stored in tblFetish, fetish column).
What is the odata syntax to acquire this?
thanks for reading! Bob
Try either:
http://localhost:51157/WcfDataService.svc/tblModels(11)?$expand=tblModelFetishes/tblFetish
or
http://localhost:51157/WcfDataService.svc/tblModels?$filter=id eq 11&$expand=tblModelFetishes/tblFetish
Just to make it clear you will not get one huge result set with all columns but the entity graph consisted of your entities.

Resources