Tag Info

Hot answers tagged

11

Since you are using this information for billing purposes, I do not see why you would not want it in the database where it can be easily queried, aggregated, reported on, and joined to other data. I also think it's much easier to maintain a single database table containing the log information than a bunch of separate log files. Same with your concern ...


5

I have seen 2 main ways: Add the timestamp of the last update of the page the use is editing in a hidden input. When committing the timestamp is checked against the current one and if they don't match it has been updated by someone else and return an error. pro: multiple users can edit different parts of the page. The error page can lead to a diff page ...


5

Initial response Some preliminary matters: As a practical matter I find it's helpful to throw in date fields for created/modified times; it makes your life much easier when debugging data problems. Pretty much any table that's not a lookup table would benefit from it. If a table is write-once, consider foregoing the modified time column. Be sure that ...


5

On the one hand I can argue this does not violate SRP, because the whole use is database communication. You could also say you have a single class in your application, because the whole class does processing of data. It doesn't work like this. If your class has: a mix of different abstraction levels; a mix of things that can be described as separated ...


4

Yes, I think you are violating the SRP. Not because you kept all of your database code in one class, but because you have database code for completely different entities (users, products, events, friends) all in one class. At the very least, separate your code into classes by the entity it's most closely related to. If you're looking for design patterns, you ...


4

After some comments and reading the question again I came to a core realization - you have an XY problem: and a related table where each row is one screenshot from a movie (with the fields 'movie_id' and 'jpeg_data') I do see a performance hit, yeah; even with only 12 images on my locally-hosted webpage I'm seeing a 5-second loadtime as it fetches ...


3

You might use three total tables (adjust table/column names and SQL dialect to taste). The first is the user table, which contains the master list of user_id's. The second is the folder table, that will contain a list of folders for users. | folders | |------------------| | id (int) | | user_id (int) | | name (varchar) | And a ...


3

For starters, at this scale, you cannot brute force it. Let's say it takes 1ms to both compute and store in an ordered list the relatedness of one tag for a given article (that seems generous on your average machine). You have to do this 500,000,000,000,000 times. Or 500,000,000,000 seconds of work, which is equal to longer than recorded human history. ...


3

Sure, you can create a database create an account on it and put it "out there" for the clients to have access to. It is possible. You will encounter things like "how many connections do you have?" and "can the admin log in from remote?" and "just how bad is it if one of the clients gets more access than they should have?" Once its "out there" anyone can ...


3

It seems you raised the question with the answer already: From my point of view, the solution I would have tried is: "... Add a new table, which tracks number of seats over time. Tuple: (HallID, numberOfSeats, validFrom, validUntil) ..." This way, you are also able to track when the number of seats was changed. Also in the code you are able to know the ...


2

Minimum occupancies of greater than 50% don't work, because when you need to split a node because the node is too full, it would be impossible to cut a node such that the two resulting nodes were greater than 50% full. (You could do 60/40 or something like that but the smaller node would always fail the data structure's invariant of each node being greater ...


2

A minimum occupancy of 1 isn't possible with a B+ tree as each node has to have one entry from the parent node. Occupancies of less than 50% means that the tree can be made more efficient by redistributing entries between nodes and if two nodes have less than 50% occupancy, they get merged into one node. Or as Billy ONeal points out, the tree grows by ...


2

First I am going to put a disclaimer: I really hope this is a school assignment project because storing account numbers and maintaining funds balance in a desktop application with a text file is unbelievably insecure and prone to error. I vehemently recommend more of a client/server/database design with security built between all layers. With that being ...


2

You don't strictly want to know the total number of seats, but the total number of seats available to be sold. For example, some seats may be in existence physically but unsellable for a given event. I'd be inclined to think about an "available seat" as a tuple of (hallId, seatId, eventId) - which you can pair up with a Reservation when it arrives. Given ...


2

You need to "read your writes", which means before you write down a change, you need to read the record again and check if any changes where made to it since you last read it. You can do this field-by-field (fine-grained) or based on a timestamp (coarse-grained). While you do this check you need an exclusive lock on the record. If no changes were made, you ...


2

First about storing file paths: Having several image path columns (imagepath1, imagepath2 ... imagepathN ) violates 1NF. Storing several comma-separated image paths in the same column also violates 1NF. When you violate the simplest of normal forms, you will have a lot of headaches in the future. The correct thing to do is create a separate table for ...


2

Here is my favorite approach: Each table has a corresponding history table Write stored procedures (or triggers) to make sure that all actions are logged to the history tables On insert, add a row to the history table with start = now() and end = 31.12.2999 On update, first update the most recent history record to end = now(). Then insert a new row with ...


2

For date of birth and people in general, one will need to validate if that person exists and if thier address is valid. You can do both of these using 3rd party services that will: Validate if the person is a real person Validate and standardize address information You can do this yourself using algorithms that you have mentioned, but why re-invent the ...


2

First you have to decide if it is sufficient to have runtime safety about the number of images or if you want to have compiletime safety. Runtime safety Achieving runtime safety is quite easy. All you have to do is remove the default setter for Images and implement a setter that performs a check before saving the given ICollection<string> argument ...


1

In the code: Validate in the setter the collection has at least one item, and raise and exception if it doesn't. In the database: Create an episode_image table. That table would have a foreign key with the image table. Unfortunately, there's no way to enforce that for every row in the parent table, there's at least one corresponding row in the child ...


1

Solving this problem is one of those situations where using a data abstraction layer (DAL) in your webservice might help you. In your DAL on the server component, realising that there is a performance issue, you could replace the DAL code which writes directly to the database with one that implements a write cache. That should allow the system to handle ...


1

The question can be reworded as "I have the canonical perfect application for a nosql key-value store, what should I do?". Yes, this can be done with sql, but a nosql implementation is likely to be more efficient. Look at systems like riak, apache cassandra, berkeley db or memcachedb, or if you're planning on deploying to amazon web services dynamodb. Or ...


1

I would recommend separate databases for the applications and one database for the user accounts. I would put any fine-grained access control within the individual applications. I would also look to make the one 'user database for the user accounts' be accessed via an authentication service using industry standard protocols such as LDAP.


1

Door number (2) is attractive if you can do it. The problem with many applications tracking long-lived facilities (theater halls and other building components, aircraft, cargo vessels, ...) is that they assume those assets are invariant. They are not. As relatively inflexible and expensive capital assets, they are not changed very often--but they definitely ...


1

Use Optimistic Concurrency Control. Add a versionNumber or versionTimestamp column to the table in question (integer is safest). User 1 reads record: {id:1, status:unimportant, version:5} User 2 reads record: {id:1, status:unimportant, version:5} User 1 saves record, this increments the version: save {id:1, status:important, version:5} new value ...


1

flask-restless supports this behaviour with it's multiple patch feature. PUT /api/person Sets specified attributes on every instance of Person which meets the search criteria described in the q parameter. I still don't know the name for this general technique, but this does what I need.



Only top voted, non community-wiki answers of a minimum length are eligible