Directus M2M Field Display as Select Box in Admin Panel - directus

I'm trying to convert a data model that uses composite keys, but I know as of version 9.14 Directus doesn't support them. I use these keys to offer clients different items from the same table. To get around this limitation, I'm using M2M relationships that offers each client the same options:
The junction table just stores the keys to save the relationships. Is there a way to add another column from the related collection in the admin panel to define what the key represents? This would help clients understand what values are assigned.
Also these M2M relationships are options to be selected in new collections. Is it possible to use a M2M relationship in a Select Box to force only one option to be selected?
Lastly, is it possible to filter all collection items based on a client ID associated with a login ID? This would allow one data model to support multiple clients. Is it possible to use SQL queries to populate collections displayed in the admin panel?
Thanks in advance for any help and direction.
Thanks,
Brandon

Related

CUBA : attributes for many-to-many association

Is there a standard way in CUBA to modelize attributes for many-to-many association ? Documentation omits the topic so I guess it is not. In this case, is this in the roadmap ?
For many-to-many association (e.g between Products and Providers), CUBA Studio generates automatically a link table (holding Provider ID and Product ID).
In order to handle specific attributes to this association (e.g Boolean preferredProvider) it would need to add the preferredProvider column in the link table and create a class holding the two IDs and the attribute.
It would also probably impact the platfom mechanism of fetching many-to-many associations.
I'm reasonably sure that CUBA Studio does not manage it as of 2.2.3 - no option in Studio GUI, nothing in doc. It is still of course possible to code the case manually but one would need to manually write JPQL. Not necessarily a big deal but losing a strong feature of the platform here just for one field.
So I created the preferredProvider field as a one-to-one association from Product to Provider, which is a valid workaround at the cost of an additional association.

How to force powerpivot relationship to be one-to-one?

Actually, I would be satisfied just getting to pick the direction of the one-to-many. I have one table, the result of a SQL query that I want to use as a lookup table. It is unique in its key column, but I don't know how to tell Powerpivot that. I have another table which is linked from Excel where the user can type in a key to look up stuff in the big table. When I use diagram view to connect these tables, it creates a many-to-one relationship in the wrong direction and then RELATED('lookuptable'[key value]) fails. There is really a one-to-one relationship between the one row supplied by the user and some row in the big table. How do I convince PowerPivot of this? The version I am using is 2016.
You can change which is the lookup/1-side table and which is the many-side, either by clicking and dragging from the many to the one, or by switching the tables in the edit relationship dialog.
Coming eventually for 2016, likely no later than the GA release of SQL Server 2016, is the concept of a bi-directional relationship in which filter will flow both ways between the tables in a relationship, and hopefully many-to-many support natively along with that.
Edit:
In the Create Relationship dialog menu, whichever table you define on the left will become the many side of the relationship, so you can simply create the relationship through this dialog.
That being said, I have confirmed that when defining a relationship in Excel 2016 by clicking and dragging fields, the field that you drag becomes the many side of the relationship, and the field that you drop on becomes the one side of the relationship. The arrow points in the direction that filter context will flow (note that this is the opposite direction of the lookup arrows in previous versions of Power Pivot). Filter context follows the arrow, but calls to RELATED() or RELATEDTABLE() go in the opposite direction of the relationship arrow. You can only call one of the RELATED*() functions from the table that the arrow points to. If you need to reverse the relationship, just delete and redefine it by dragging from the other table.
To modify the relationship in the Edit Relationship dialog menu, you will need at least three tables in the model, and you will then need to juggle the tables, using the third table to allow selection of the first two appropriately.
Edit 2:
It turns out that the edit relationships dialog launched by Relationships in the pivot table Analyze ribbon menu does not behave in the same way as the Power Pivot dialog, and so the following works to switch relationship direction regardless of how many tables are in your model. Table is the many side, Related Lookup Table is the one side.
One to one relationship is currently not supported in Power Pivot for Excel. It looks like it is only supported in Power BI.
See links:
https://exceleratorbi.com.au/relationships-power-bi-power-pivot/
https://social.msdn.microsoft.com/Forums/en-US/9aafb848-8853-40a5-b91f-f6094779c99e/onetoone-relationship-not-working?forum=sqlkjpowerpivotforexcel

BizAgi Tables and m-m relationships

BizAgi tables are used to view collections in 1-m relationships.
It is also possible to view m-m relationships from the point of view of one entity (thus, a 1-m relationship).
The add and delete buttons don't work with m-m relationships and no errors appear.
Has anybody used them successfully?
My interpretation with an example:
One contract has N clients, and one client has N different contracts. You want to use collections to represent this connection.
The only was I see of representing this information is to have a table of contracts, to which the edit/detail form shows a table of clients for that contract.
You might also want to consider using a form link as a column of that table.
Let me know if this is a correct interpretation.

Associative Relationship With Multiple Tables (MS Access)

I've not really used access for a while and not too sure how best to proceed with this data model:
I have set of resource tables of differing type, eg: Data, Literature, Contractors, etc.
I also have a set of category tables such as Procedures, Topics, and Regions.
I need to create many-to-many relationships between the various resources and the various categories so it is possible to view a resource record and see lists of the various categories to which the resource is allocated, and vice-versa, that is to view all resources allocated to a specific category.
I realise that I could create lots of link tables, eg: LnkDataProcs, LnkDataTopics, etc, however with perhaps 10 resource tables and 3 category tables I would wind up with 30-odd link tables which seems wrong (it may also be useful to query all resources from each category anyway so it would be good to have one link table for each category).
I've done this kind of thing before using SQL in custom DB client apps by using one link table with fields as follows: CategoryTable, CategoryID, ResourceTable, ResourceID - So that the link table stores the table name as well as the foreign key.
However I'm not too sure how to fit this kind of model into an access database, it would be nice to use the Access framework (master-child form objects) rather than having to write loads of custom code to perform queries and populate forms.
Any ideas how to proceed, or even what this kind of relationship is called?

Proper way to store user defined data in SQL

I want to build an online form builder much like wufoo that allows the users to create and publish their own web forms. Each submission should be saved to a data base where the user can later retrieve the submissions.
As these forms will be dynamic, ie. the user has complete control over the amount and type of form fields I am trying to think of a solid database design to store this information.
I would have one table fieldtype which contains every type of field available to the users, ie. textfield, emailfield etc.
One baseform table which will hold each forms id, url etc.
I would then have a table formfields which would contain ref to the baseform and to fieldtype, this table could also include custom validation to be done on each field.
Is this design good as a base structure? I imagine it will be easy to add new types of fields to the application however I don't know what the potential downsides are as I am far from a sql expert.
store user defined data in SQL
I think you are looking for the Entity–attribute–value database model in which:
The basic idea is to store attributes, and their corresponding values,
as rows in a single table.
Typically the table has at least three columns: entity, attribute, and
value. Though if there is only a single relevant entity, e.g. a table
for application configuration or option settings, the entity column
can be excluded.
See this pages as a start:
Using Database Metadata and its Semantics to Generate Automatic and Dynamic Web Entry Forms (pdf)
Planning and Implementing a Metadata-Driven Digital Repository (pdf)
I retagged your question with entity-attribute-value tag, in which you can browse a lot of threads that relate to your case.
As Mahmoud Gamal writes, The model you describe is "Entity/Attribute/Value"; as Borys writes, there are many known problems with this model.
As an alternative, you might consider storing the form entries in a "document" - e.g. XML or JSON - within a relational model.
For instance, you might have a table along the lines of:
FORM_SUBMISSION
--------------------
Submission_ID (pk)
Client_ID (fk to clients table)
Submission_date
SubmissionDocument
I'm using "client" to represent the users who create the form; to retrieve all submissions for a given client, you use a where clause on client_id.
This model makes it harder to run SQL queries against the form submission (though that becomes hard with EAV too when going beyond very simple queries), but it dramatically simplifies the persistence solution.