Welcome Guest, Not a member yet? Register   Sign In
Datamapper and ID field
#2

[eluser]WanWizard[/eluser]
You need the primary key to uniquely identify a record. In your example, there is no way to do that, so how are you going to delete or modify a single employee record?

You may think that you have defined a one-to-one (which by the way isn't a relationship that exists in Datamapper), but you can easily have multiple employee records with the same user_id (for example someone that works part-time for two departments?).

You will have to make this a one-to-one in your application code, by making sure you don't create one with a given user_id while another one exists. Datamapper is not aware of that.

For this to work, you will need a "belongs_to" type of relation, which doesn't exist in Datamapper. It will also need complete new logic for interacting with tables, making the library even more complex.


Messages In This Thread
Datamapper and ID field - by El Forum - 04-26-2012, 04:02 PM
Datamapper and ID field - by El Forum - 04-26-2012, 11:40 PM
Datamapper and ID field - by El Forum - 05-01-2012, 12:21 PM
Datamapper and ID field - by El Forum - 05-01-2012, 11:43 PM



Theme © iAndrew 2016 - Forum software by © MyBB