How do I implement a database
How do I implement a database / table as a batch?
I have a state machine that needs to push / paste some filenames for different users. I would traditionally use stacks as the data structure choice, but this has to be done using a database as I have no way of maintaining the data structure between incoming web requests.
I was wondering how I can implement the stack functionality using databases.
I have to support:
- push (filename, user): Push a filename for the user
- pop (user): Pop the top filename for the user
I'm working as a prototype of an idea, so I'm using sqlite3 with Python.
If you are wondering which database to use, it really depends on your personal preferences and what you expect from it. Since I'm only familiar with MySQL, I'll answer the other part of the question assuming MySQL:
You want to use because your table will be write intensive and with large tables the row locking of INNODB is life saving.
As far as table design goes, apparently all you need is one table:
I chose any 'id' column as the primary key is replicated in each entry of each index. So entering a primary key of (user, filename) can cause performance issues if your filenames are extremely long.
The size of your ID column depends on how big your table gets. With unsigned smallint you get 65,000 lines.
Username and filenames are varchar as they are drastically different in length I assume.
This is just one way to organize your results by when they were pasted (helpful for your POP).
If you are considering an Oracle database, consider Advanced Queuing with a last in first out (LIFO) queue pattern.
At the most basic level of the queue, a producer queues one or more messages. Each message is queued and processed once by one of the consumers. A message remains in the queue until a consumer removes it from the queue or the message expires. A producer can set a delay before the message is available for consumption and a time after which the message expires. Similarly, a consumer can wait when trying to remove a message from the queue when no message is available. An agent program or application can act as both a producer and a consumer.
- What is a handicap in special education
- How do I prevent ingrown hairs
- What is life math
- Trump signs a paper without reading it
- What is xanthan gum
- What is the price for 5G spectrum
- Works super glue on faux leather
- Who is the greatest president
- If x 28 17 what is x
- Why are science fiction books so ignored
- Can a Christian believe in extraterrestrials?
- Why is Kangna Ranaut overrated?
- How do we describe a rich person
- Which famous writers did not graduate
- Will Sunil Narine play IPL
- How bad does an airbag hurt
- What is philosophy in education
- What is your personal favorite protein meal?
- What is paranoia
- Why are people so intimidated by homosexuals
- CA is all about memorization
- What is the coverage of cell phones in Minnesota
- Has privatized the Indian airport authority
- How do I get into someone's messenger