SunQuest
           Dev Shed Lounge
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOtherDev Shed Lounge

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old March 25th, 2003, 03:46 PM
heyder heyder is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2002
Location: t.o.
Posts: 82 heyder User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 m 55 sec
Reputation Power: 7
selling one of a kind items online

I have a cleint who wants to sell one of a kind items online. I'm not sure if this would even be possible.

ie..what happens when two people are on the website and they are both looking at the same item and one of them decides to buy it?

Anyone ever tried anything like that?

Reply With Quote
  #2  
Old March 25th, 2003, 04:23 PM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is offline
Banned ;)
Dev Shed God 5th Plane (7000 - 7499 posts)
 
Join Date: Nov 2001
Location: Glendale, Los Angeles County, California, USA
Posts: 7,442 Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 1 h 26 m 13 sec
Reputation Power: 797
>> I'm not sure if this would even be possible.
Yes, it is possible. If it wasn't possible, online ticket reservations would never work. This is trivial if your database backend supports transactions.

Reply With Quote
  #3  
Old March 25th, 2003, 04:23 PM
wannabe wannabe is offline
=) wannabe?
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jul 2002
Location: florida
Posts: 2,153 wannabe User rank is Lance Corporal (50 - 100 Reputation Level)wannabe User rank is Lance Corporal (50 - 100 Reputation Level)wannabe User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 21 h 58 m 25 sec
Reputation Power: 9
Send a message via AIM to wannabe Send a message via Yahoo to wannabe
you could do it the way,

when they're not able to buy it directly but when they click buy the time is saved, whoever clicked first wins, and the other gets an e-mail saying "get faster connection loser".

or maybe an auction. e-bay has tons of one of a kind items, and seems to work pretty good.

just opinions

Reply With Quote
  #4  
Old March 25th, 2003, 05:14 PM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is offline
Banned ;)
Dev Shed God 5th Plane (7000 - 7499 posts)
 
Join Date: Nov 2001
Location: Glendale, Los Angeles County, California, USA
Posts: 7,442 Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 1 h 26 m 13 sec
Reputation Power: 797
Any database that supports transactions (such as SQL Server, Oracle, Informix etc.) and locking should be able to do this. By definition, a transaction is guaranteed to be atomic. So if a process tries to select and update tables within a transaction, other processes that are trying to access the same tables are paused until the first process explicitly ends its transaction. For the purposes of this explanation, assume that there is a table called RESERVATIONS in the database, that contains a list of seats. This table will be updated when someone reserves a seat. The set of steps would be:
Code:
1. Begin Transaction
2. Lock the RESERVATIONS table and reread the data from the RESERVATIONS table,
    to ensure that the data hasn't changed from when we last read it.
3. If the data hasn't changed from the last read, update the RESERVATIONS table to mark 
    this entry as reserved.
4. Unlock the RESERVATIONS table.
5. End transaction


Now assume person A and person B have read the RESERVATIONS table and noticed that seat #20 (which is the best seat in the house) is available. They are both trying to pick the same seat. Now, both of them attempt to begin a transaction, but only one of them (let's say it's person A) will be allowed to do so. The other person's (person B) request will be put on hold while the database executes the transaction for person A.

So person A's process locks the table, rereads the data to make sure that the data hasn't changed since it was read. Then person A's process updates the table, unlocks the table and ends the transaction.

Now, after person A's transaction is ended, person B's process (which was paused on step 1, by the database engine) is allowed to execute. So, person B's process locks the table and rereads the data. Then it notices that the data for that seat has changed since it was last read (which was when it was shown as available). Hence, the process unlocks the table and exits the transaction, without updating the table. Person B is then notified that their reservation attempt failed and therefore resolves to get a faster connection.

Hope this helps

Last edited by Scorpions4ever : March 25th, 2003 at 08:31 PM.

Reply With Quote
  #5  
Old March 25th, 2003, 06:28 PM
heyder heyder is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2002
Location: t.o.
Posts: 82 heyder User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 m 55 sec
Reputation Power: 7
I was aware that tables get locked etc.. but your example clarifies how that works.

So... say

Two users are on the website. They both see an item click on it...check out the info. Than if they both try to buy the item the process you talked about happens correct?

I'm a unsure of what you mean by supports transactions. I plan on using mySQL which I would assume is fine but...not sure.

Reply With Quote
  #6  
Old March 25th, 2003, 06:47 PM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is offline
Banned ;)
Dev Shed God 5th Plane (7000 - 7499 posts)
 
Join Date: Nov 2001
Location: Glendale, Los Angeles County, California, USA
Posts: 7,442 Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 1 h 26 m 13 sec
Reputation Power: 797
>> Two users are on the website. They both see an item click on it...check out the info. Than if they both try to buy the item, the process you talked about happens, correct?

Yes.

>> I'm a unsure of what you mean by supports transactions
The real use of transactions is that you can start one, make a bunch of changes to different data. Then, until you commit the changes, they are not applied to the database permanently. So, if you make some changes to some data tables and then decide not to apply the changes, you can roll back the transaction and all your changes will be unsaved. This is especially helpful, if you need to update a bunch of tables.

>> I plan on using mySQL which I would assume is fine but...not sure.
mySQL didn't originally support transactions, but now they do, if you turn on the InnoDB extensions. However, this makes mysql a little slower. I personally haven't used mysql with InnoDB.

What you need is the ability to lock a table (or a row within the table).

Reply With Quote
Reply

Viewing: Dev Shed ForumsOtherDev Shed Lounge > selling one of a kind items online


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway