>> Whether it is a UUID created in ColdFusion or some other unique value...you >> KNOW what it is...every time, because you set it, not the DB.
Until you need to use another database client, one other than ColdFusion, then things get messier. If you need to manually insert rows, or do a batch import, or ... This is the main reason I'm not a big fan of database clients (any clients, including ColdFusion) generating PKs. --- Ben -----Original Message----- From: Mark Fuqua [mailto:[EMAIL PROTECTED] Sent: Monday, March 24, 2008 10:00 AM To: CF-Talk Subject: RE: Any "Gotcha's" in using CF UUID for db record primary key? What if you have four concurrent users (or four hundred if your app get popular!), what happens if user two gets user three's id when she runs LAST_INSERT_ID()? That's the one of the only reasons I can see for using alternate keys. Whether it is a UUID created in Coldfusion or someother unique value...you KNOW what it is...everytime, because you set it, not the DB. Mark -----Original Message----- From: Rick Faircloth [mailto:[EMAIL PROTECTED] Sent: Monday, March 24, 2008 8:22 AM To: CF-Talk Subject: RE: Any "Gotcha's" in using CF UUID for db record primary key? What's the reason for using the db instead of CF to generate the UUID? To keep the load off CF? I was thinking I might use CF in the following manner to generate a UUID for a record: - Create UUID and variable to hold UUID via CF and cfset - User completes form with textual information and photo selection via cffile - Run insert query to create primary textual record, including inserting UUID - Run second insert query to create records in photo table for each cffile field mentioned above, inserting UUID for relational key to textual information After doing some reading in the MySQL 5 docs, it looks like I could use the LAST_INSERT_ID() function to return the auto-incrementing primary key of the "main" textual record of a property (Real Estate property), then run an insert query for the photo records on another table, using the LAST_INSERT_ID() as the relational key to the primary property table. - User completes form with primary record info and selects photos - Insert query runs creating primary property record - Run another query to retrieve LAST_INSERT_ID() (or just use that value as a variable, #LAST_INSERT_ID()# ???) - Run another query to insert photos into photo table using LAST_INSERT_ID as relational key Using LAST_INSERT_ID(), it seems that I could allow a single input form for two tables, property and property_photos, create a more user-friendly work flow, and avoid the "messiness" of UUID altogether. Thoughts? Rick > -----Original Message----- > From: Dave Watts [mailto:[EMAIL PROTECTED] > Sent: Sunday, March 23, 2008 11:48 PM > To: CF-Talk > Subject: RE: Any "Gotcha's" in using CF UUID for db record primary key? > > > At the same time I kind of DON'T agree with them if you're > > doing what we were doing: if you're using the key to link > > tables (so that you can combine multiple databases easily) > > and using them to link to non-DB information (log files, etc) > > then it seems like extra work to do a "real" auto-increment > > PK as well. > > I'll second this. Either use UUIDs or don't. In either case, I'd recommend > that you use your database's ability to generate these instead of doing it > from CF. > > Dave Watts, CTO, Fig Leaf Software > http://www.figleaf.com/ > > Fig Leaf Training: Adobe/Google/Paperthin Certified Partners > http://training.figleaf.com/ > > WebManiacs 2008: the ultimate conference for CF/Flex/AIR developers! > http://www.webmaniacsconference.com/ > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;160198600;22374440;w Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:301904 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4