Parse server removing object from relation when I adding a object to relation that already exist - parse-server

I am running open source parse server. I have an table and in the table I have a relation field.
I am adding a new object to relation using add
relation.add(offer);
But the problem is if offer already exist in relation then this query removing offer from relation instead of add.
Is there any solution?

Related

You cannot add or update record (MS Access)

Can someone help me? I am really new to access and vb . net. Every time i try to enforce referential integrity in my database relationship and add records or update a record I a always get a message of "You cannot add or update record because a related record is required in the table tbProducts"
Here is my database relationship.Database Relationship
The problem would likely be that a Foreign Key reference is required in your tbProducts table, the only one I can see from your image is UserID. (from the tbStaff table)
If you're trying to insert a record into the tbProducts, make sure that there is an existing UserID value to match what your inserting.

linking foreign Key of unknown table in a relational database

I am currently trying to set up a relational database (H2) that projects an object orientated structure of JAVA Model into the relational tables of my database. I am using the JDBC and H2 RDBMS.
So Here is my problem:
I have an object of type "attribute" that is supposed to be stored in the table "attribute". The owner of this attribute can either be an object of type "Function" or of type "Block" who both have a table on their own. One attribute-object can only be owned by one object (either function or block), making this a 1:n cardinality.
I am however struggling with how to include the owner in the attribute table. If I create a table named "ownerID" and store the ID of the owner (a globally unique ID btw) in it, the Database is missing the information about which table is containing this ID (even though its a GUID).
-Is it okay for example, to include another column containing the name of the table that the owner_ID belongs to ?
-another idea was to include one "functionOwnerID" column and one "blockOwnerID" and leaving one of them empty, but this seems like a rather dirty solution to me.
I hope my description of the problem was clear, and thanks in advance !
best regards,
Moritz
"Is it okay for example, to include another column containing the name of the table that the owner_ID belongs to ?"
That's how polymorphic relationships work! :)
Edit: (yes, you can do that and it's actually pretty common)
References:
(Rails/ActiveRecord Docs): http://guides.rubyonrails.org/association_basics.html#polymorphic-associations
(Laravel/Eloquent Docs): https://laravel.com/docs/5.4/eloquent-relationships#polymorphic-relations

Two entities with possibly different keys are mapped to the same row

I have Table
Field1 PK int not null
Field2 PK int not null like this
when i want to map this table I get this error
Error 3 Error 3034: Problem in mapping fragments starting at lines 2212, 2218:
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.
And I tried to delete and re-create that table inside model. When i add table it gives another error but at the end i always get this error
How can i handle this problem please help me...
When i investigate the problem, i realised something becuse i read an article before for this data model situation and i understand the why the problem occur. (Problem in mapping fragments in Entity Framework)
Actually problem comes from table mapping because i said that table has many to many relationship so That article says if you put that table in the model design it always gives us this error and finally when we delete that table on design side and add table silently in data model so program can be build. I ‘m telling you this because maybe you can make an idea for this because i learned this and when i add new view in model and vs doesnt give me any error.
This is the old model picture when the delete that table inside red box The program doesn't give any error and continiue to use bottom table
If nothing else works, try deleting and recreating the whole .edmx-file.
I got this problem when I added a couple of many-to-many tables to an existing Entity Framework 6.2 project.
I tried removing and regenerating all tables in the model. Nothing seemed to work. I believe there was some "junk" somewhere in the EF project causing the problem.
When regenerating the edmx, I added all tables in the project, including the many-to-many tables.
solution for error:3034
PK UserId;
PK RoleId
two primary key cannot allow edmx file.so create sno column in that table and make that as primary key . remove the pk of UserId and RoleId.
now in that two column there is no primary key available.
like
Pk sno;
FK UserId;
FK RoleId

ADO Entity Framework creating unwanted Entity Key

I need to use tables from a DB which I cannot alter (using linked server).
So part of my schema is a view on these table and I cannot create an FK in my DB.
When I come to creating the association in ADO.NET Entity Framework I am getting problems because a second column on the table from the external DB has an index on it and the EF is creating an Entity Key for it (it's the name descr of the record - I think they just wanted to speed the ordering on it).
When I take the Entity Key off this column in the EF entity it complains that I need it because the underlying table has a key on it.
If I leave it in I cannot map it onto anything in the table mapping of EF.
Does anyone know what I should do please?
You will have to edit the XML and remove the column from the key. Find the <EntityType> tag in the <edmx:StorageModels> section (SSDL content). Delete any <PropertyRef> in the <Key> that is not actually part of the primary key.
Once you do this, you can set "Entity Key" on the corresponding scalar property in the designer to false, and EF won't get mad. You will also not be asked to map this column in associations anymore.

Association end is not mapped in ADO entity framework

I am just starting out with ADO.net Entity Framework I have mapped two tables together and receive the following error:
Error 1 Error 11010: Association End 'OperatorAccess' is not mapped. E:\Visual Studio\projects\Brandi II\Brandi II\Hospitals.edmx 390 11 Brandi II
Not sure what it is I am doing wrong.
I believe I can add some more clarity to the issue (learning as I go):
When I look at the Mapping details and look at the association, the column for operatoraccess table (from above) is blank and the drop down only includes field from the linked table.
The Entity Framework designer is terrible - I've had the same problem many times (and your problem too, Craig):
This happens when you have a many-to-one association which is improperly setup. They could very easily fix the designer to make this process simple; but instead, we have to put up with this crap.
To fix:
Click on the association, and go to the mapping details view.
Under association, click on Maps to <tablename>. Choose the table(s) which make up the many side of the relationship (ie. the table(s) which make up the *-side of the association in the designer)
Under Column, choose the table-columns which map to each entity-side Property. You get this error when one of those entries are blank.
I had the exact same problem and this is what I did to fix it.
Make sure you have an Entity Key set in your designer on the tables your making an association with. Also check that StoreGeneratedPattern is set to Identity for that Entity Key.
There's not a lot of information in your question, but, generally speaking, this means that there is an incompletely defined association. It could be that you have tried to map one table with a foreign key to another table, but have not mapped that other table. You can also get this error when you try to do table per type inheritance without carefully following the steps for implementing that feature.
Not sure of the answer, but I've just posted a similar question, which may at least help clarify the issue you are experiencing.
Defining an Entity Framework 1:1 association
I had to go back into the database itself and clarify the foreign key relationship
I had this problem in the case where I was creating both many to 0..1 and 0..1 to 0..1 associations. One entity needed associations to multiple tables, and that entity did not have foreign keys defined for those tables.
I had to do the table mappings step that is given in the accepted answer, but note that it wasn't only for many to many associations; it applied to all the types of associations I added for this entity.
In the Mapping Details view, I had to select the entity with the non-foreign key ID columns to the various tables. This is not always the "many" side of the relationship. Only there was I able to map the related entity property to the appropriate property in the original entity. Selecting the "destination" entity would not allow me to select the properties that I needed to, and the error would still exist.
So in short, I had to map using the table related to the entity that had the "non-foreign key" ID fields corresponding to the various entities' (and their tables') primary keys that I needed to associate.
Entity A
various other properties...
Id
ContactId
OrderId
etc.
Contact entity
Id
FirstName
LastName
etc.
In the mapping details, I selected Entity A's table. It then showed both ends of the association. I mapped its Entity A's Id property to its table's actual ID column (they had different names). I then mapped the Contact entity's Id field to the ContactId field on the A entity.
Simply select the many relationship table (*) from the Association>Edit Mapping & select the appropriate relationship