Interesting discussion on unsaved records

28 views
Skip to first unread message

svandragt

unread,
Mar 12, 2014, 5:06:52 AM3/12/14
to silverst...@googlegroups.com
Hi group,

I know that the topic of saving unsaved records and their ID comes up often in relation to things like relations etc and perhaps everyone is happy with how this behaviour is handled by the framework.
I noticed that a similar issue is being discussed by Marco Arment for his FCModel (iOS Core Date alternative) and he's proposing to assign a random 64bit integer or GUID to a record so that it can be identified immediately.
I throughout this might be interested to the group:

For the full discussion see:
https://github.com/marcoarment/FCModel/issues/33

Will Morgan

unread,
Mar 12, 2014, 11:15:57 AM3/12/14
to silverst...@googlegroups.com
+1

This would certainly make relationship handling a lot easier. Especially in SS where Created is an automatically appended column, it doesn't make sense that you should be ordering records by ID because it is never a guarantee that AUTOINCREMENT IDs are chronologically sequenced.

We can also do away with that annoying "save your record before attaching things" behaviour.

Hamish Friedlander

unread,
Mar 12, 2014, 5:34:01 PM3/12/14
to silverst...@googlegroups.com
It would also solve the problem when trying to merge data from two different databases of colliding keys.

However 64 bits isn't really enough to ensure uniqueness on randomly generated keys. I'd consider 128 bits a minimum (UUIDs are 128bit, git sha hashes are 160bit) and 128 bits isn't a standard integer column type.

There are some options (multiple bigints, binary, char), but we'd definitely need to check performance impact before using them. Because we do MTI, key performance in joins is very important in SilverStripe. http://dba.stackexchange.com/questions/15897/mysql-int-vs-varchar-as-primary-key-innodb-storage-engine indicates a very heavy performance impact for using varchars.

Hamish Friedlander


--
You received this message because you are subscribed to the Google Groups "SilverStripe Core Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to silverstripe-d...@googlegroups.com.
To post to this group, send email to silverst...@googlegroups.com.
Visit this group at http://groups.google.com/group/silverstripe-dev.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages