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.
Related
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
I have three entities that need to be linked. In my scenario, I have three tables users, stores and accounts.
Both users and stores can have zero or one account and each account should be either for a store or a user (see image below).
I need a one-to-one relationship between user-account and store-account. Since one-to-one relationship force the model to use one key, the user and store Ids might have conflict.
Is there any solution for this in Entity Framework or do I have a flaw in my design?
It would be much easier to use intermediate tables user_account and store_account, that would store only keys. This way you can enforce any logic you want.
I found this solution for a problem I have: how to generate entities with JPA annotations from a given database.
IntelliJ IDEA 10 generate entity (POJO) from DB model
Now with IntelliJ I'm given the possibility to create relationships between entities manually. Is there a way to generate them automatically as it did with entities?
I used the REFERENCES keyword when needed while creating the database. I suppose there should be an automatic mapping of relationships as well!
When Generating entities from DB Schema in dialog there is an option to 'Show default relationships' which when selected will display FK relationships when selecting tables to generate entities from:
I know that each time a user registers in my ASP.NET MVC application the ApplicationUser class is used to create the new record and put it in the database.
I was wondering if it's okay to add properties to that class for example I want the model to have a column in the database for DateOfBirth. Then use that class(model) directly in my application when I have to do some business logic things, database queries and similar stuff. Or is it more correct to create a new table in the database called let's say ApplicationAccounts, that saves the general info about the account. Each ApplicationAccount will be associated with a ApplicationUser(1 to 1 relation) and be somewhat of a buffer in the communication with the real accounts. Does that make sense?
I would go with the second option : create your own table, link them up in a one to one relationship using the UserID as a unique foreign key and then go from there.
One note here, it is perfectly normal for the model you need for the views to be different from the database model, this is because your db model can hold a lot of data that your view doesn't actually need. You might want to consider having separate models and use something like Automapper for a quick translation from one to another.
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.