3 tables for 1 pivot - laravel

Has anyone tried to make a pivot on 3 tables?
My case is a project management.
I have projects that contain multiple customers that contain multiple tasks.
I wish I could recover all cascaded
Project::with('customers')->with('customers.tasks')->get()
I have tried several times but nothing conclusive.
To give you an idea of the result: http://dhtmlx.com/docs/products/dhtmlxGantt/01_basic.html
We have: Product launch (project) > Development (client) > Develop System (task)
Each task has a start date and an end date. So I have to be able to find these dates since the project itself (represented by the green bar).
If you have any ideas let me know :)

I think your best bet would be to create a pivot table between customers and tasks. And it would also have a column for project_id.
This would give you the ability to find all of the customer's tasks and all tasks belonging to a certain customer.
Then you would have a projects table, and you'd be able to find a project's customers/tasks using hasManyThrough. I believe this would also require you to setup a model for your customer_task table as well, but should be fairly straight forward.

Related

Is it ok to have multiple models for 1 table

When employees log in through
site.com/employees/login
They get to access the vendor_companies table through
App\Models\Employee\VendorCompany Model
When vendors log in through
site.com/vendors/login
They get to access the vendor_companies table through
App\Models\Vendor\VendorCompany
Is this approach ok?
Although having a single model is most common, what you have is fine. There are times when you want to do customization in one model depending on how you want to treat Vendors. Two different models allow you to have a cleaner separation and makes it easier to maintain functionality, especially between two teams - one team that builds vendor features vs. other team that builds features for employees.
When you build your controllers, you will have to put additional effort to identify whether you are dealing with vendor or employee and then call the appropriate model.
On the flip side, it is common to have a single model and you have customization based on vendor or employee. Give your method a shot and try your methodology.

informatica power center. find dependency view in repository metadata

I have a question about informatica metadata, and i will be glad for any advices.
We can rightclick on any workflow in Informatica power center and choose
"Dependencies". After it, we see the window, where we can choose, what dependent objects we want to see.
When we press "OK", appears "VIEW Dependencies" window with list of dependent objects and info about them (object_name, object_type, timestamp, status, etc).
Does anybody know, how to select this list from informatica metadata repository tables? Or may be somebody know the way, how can i extract this select from power center designer.
I know about separeted views with mappings, sources, targets, etc, but may be you know, how to get exactly the same data, as on this window.
Thank you for any help
You need to realize that these data are in many different tables in the repository database, and it will be even more complex if you have versioning turned on in the repository.
We created a query that gives all dependent tables (sources, targets and lookup sources) for a workflow, but that took two of our smartest people more than a week, and still it has several drawbacks in a more generalized setting. One example is that it doesn't support worklets since we don't use it...
Can you narrow down the requirement, then we may be able to point you in the right direction?
We can check the dependencies through querying the Informatica repository Metadata tables. But for that we need to know the oracle connection details in which the metadata tables are resided(Mostly Informatica admins knows about the connection). If we get the connection details we can check the below tables:
OPB_MAPPING,
OPB_SUBJECT,
OPB_WIDGET(for transformations),
OPB_TASK,
OPB_WFLOW_RUN etc
Below is the sample SQL query that shows the names of all the Folders in the repository and the mappings contained in them along with last saved date, mapping version number and versioning comments, if any.
SELECT
S.SUBJ_NAME FOLDER,
M.MAPPING_NAME MAPPING,
M.VERSION_NUMBER VERSION_NUMBER,
CASE WHEN M.IS_VALID = 1 THEN 'YES' ELSE 'NO' END IS_VALID,
M.LAST_SAVED SAVED_ON,
M.CHECKOUT_USER_ID,
M.COMMENTS
FROM OPB_MAPPING M, OPB_SUBJECT S
WHERE M.SUBJECT_ID = S.SUBJ_ID
AND is_visible = 1
ORDER BY 1, 2, 3;

create views in filemaker

I am trying to make something like this in Filemaker Database views.
The database will contain employees and projects. There need to be two combined views. One displaying the list of employees and which projects they are on in which week and by which percentage. The other one displaying the list of projects and which employees are on it in which week by which percentage. For each employee and each project there need to be a sum of percentages for all assigned projects / employees.
I have made three tables in my database:
employee
projects
employee_on_projects
Now I want to create these views. Can anybody tell me how to do this from scratch?
Thanks in advance.
FileMaker is not a good tool for creating cross-tab reports, as it has no native functionality to build these. It has to be done manually. Do a search on cross tab reporting in FileMaker and you will get some ideas.
Traditionally you need relationships and fields to hold and display your data.
On the top of my head, in this case I would probably use merge variables for displaying progress and other calculated data to avoid having fields for all those weeks. A script would gather the data using ExecuteSQL and calculate the variables. The whole thing could even be generated in HTML and displayed in a web viewer.
This way you should get away without too many relationships and fields.
If you want a simpler, but more cluttered solution, you could go with regular fields for all 53 weeks and use a sub summary report. Each field could be set up with ExecuteSQL if possible, to avoid having a relationship for each period.

TCR 2.1.1 importing ITM reports

I am trying to run some reports in TCR I imported from the 6.2.3-TIV-ITM_TMV-Agent-Reports-FP0001
Seeing that I get this error: UDA-SQL-0196 The table or view "KSY_SUMMARIZATION_CONFIG_DV" was not found in the dictionary.
I checked and the table is not in the database.
Seeing that regarding that table it says this:
The Summarization and Pruning configuration is shown in a specific query subject (Summarization and Pruning Configuration). The result is one row that represents the most recent entry in the KSY_SUMMARIZATION_CONFIG_DV view.
Maybe the WAREHOUS is lacking something? If the agents are running shouldn't there be a view named KSY_SUMMARIZATION_CONFIG_DV?
I don't seem to find other tables like: KLZ_CPU_HV, KLZ_CPU_DV, KLZ_CPU_WV, KLZ_CPU_MV,
KLZ_CPU_QV, KLZ_CPU_YV
Thanks for your help
You have to configure historical collection for the appropriate agent attribute groups for those tables to show up in your TDW. For instance create a historical collection for the "Linux CPU" attribute group to get the KLZ_CPU table. For tables ending in _D, _H, etc, configure hourly, daily, etc, summarization for those attribute groups.
Depending on collection intervals eventually the warehouse proxy agent will create the necessary tables.

Very slow search of a simple entity relationship

We use CRM 4.0 at our institution and have no plans to upgrade presently as we've spend the last year and a half customising and extending the CRM to work with our processes.
A tiny part of model is a simply hierarchy, we have a group of learning rooms that has a one-to-many relationship with another entity that describes the courses available for that learning room.
Another entity has a list of all potential and enrolled students who have expressed an interest in whichever course.
That bit's all straightforward and works pretty well and is modelled into 3 custom entities.
Now, we've got an Admin application that reads the rooms and then wants to show the courses for that room, but only where there are enrolled students.
In SQL this is simplified to:
SELECT DISTINCT r.CourseName, r.OtherInformation
FROM Rooms r
INNER JOIN Students S
ON S.CourseId = r.CourseId
WHERE r.RoomId = #RoomId
And this indeed is very close to the eventual SQL that CRM generates.
We use a Crm QueryEntity, a Filter and a LinkEntity to represent this same structure.
The problem now is that the CRM normalizes the a customize entity into a Base Table which has the standard CRM entity data that all share, and then an ExtensionBase Table which has our customisations. To Give a flattened access to this, it creates a view that merges both tables.
This view is what is used by the Generated SQL.
Now the base tables have indices but the view doesn't.
The problem we have is that all we want to do is return Courses where the inner join is satisfied, it's enough to prove there are entries and CRM makes it SELECT DISTINCT, so we only get one item back for Room.
At first this worked perfectly well, but now we have thousands of queries, it takes well over 30 seconds and of course causes a timeout in anything but SMS.
I'm given to believe that we can create and alter indices on tables in CRM and that's not considered to be an unsupported modification; but what about Views ?
I know that if we alter an entity then its views are recreated, which would of course make us redo our indices when this happens.
Is there any way to hint to CRM4.0 that we want a specific index in place ?
Another source recommends that where you get problems like this, then it's best to bring data closer together, but this isn't something I'd feel comfortable in trying to engineer into our solution.
I had considered putting a new entity in that only has RoomId, CourseId and Enrolment Count in to it, but that smacks of being incredibly hacky too; After all, an index would resolve the need to duplicate this data and have some kind of trigger that updates the data after every student operation.
Lastly, whilst I know we're stuck on CRM4 at the moment, is this the kind of thing that we could expect to have resolved in CRM2011 ? It would certainly add more weight to the upgrading this 5 year old product argument.
Since views are "dynamic" (conceptually, their contents are generated on-the-fly from the base tables every time they are used), they typically can't be indexed. However, SQL Server does support something called an "indexed view". You need to create a unique clustered index on the view, and the query analyzer should be able to use it to speed up your join.
Someone asked a similar question here and I see no conclusive answer. The cited concerns from Microsoft are Referential Integrity (a non-issue here) and Upgrade complications. You mention the unsupported option of adding the view and managing it over upgrades and entity changes. That is an option, as unsupported and hackish as it is, it should work.
FetchXml does have aggregation but the query execution plans still uses the views: here is the SQL generated from a simple select count from incident:
'select
top 5000 COUNT(*) as "rowcount"
, MAX("__AggLimitExceededFlag__") as "__AggregateLimitExceeded__" from (select top 50001 case when ROW_NUMBER() over(order by (SELECT 1)) > 50000 then 1 else 0 end as "__AggLimitExceededFlag__" from Incident as "incident0" ...
I dont see a supported solution for your problem.
If you are building an outside admin app and you are hosting CRM 4 on-premise you could go directly to the database for your query bypassing the CRM API. Not supported but would allow you to solve the problem.
I'm going to add this as a potential answer although I don't believe its a sustainable or indeed valid long-term solution.
After analysing the indexes that CRM had defined automatically, I realised that selecting more information in my query would be enough to fulfil the column requirements of an Index and now the query runs in less then a second.

Resources