New answers tagged

1

TL;DR: Depends on what you want to achieve I read a lot about using ongoing numbers vs UUID's as the primary key and had an idea how it might be possible to combine both and profit from their advantages, without their disadvantages. Have you also read, why people use UUID's as external ids? Stating the goals of this would greatly help answering this ...


1

The main flaw is complexity. The first concern should be what you are protecting by making part of the URL random. If it's confidential or otherwise valuable information you want a whole lot of randomness in there, so that it's completely infeasible, even with a large bot net, to guess even a single one. The second concern is why the order of the URLs is ...


0

I agree entirely with your approach. • Internally within the database, auto-incrementing integers work just fine. But ... • Externally-visible tokens should be UUIDs, or something similar. (Your random-string is fine.) It's a so-called "moniker," or "handle." These values should be stored in a separate field with a UNIQUE index. In true ...


0

What do you want to achieve: would you like a forum where replies are posts like any others,except that they refer to a previously existing post? In this case, you may want the option 1, but with only one forum_post table that is associated with itself. This model organises the posts as a tree (or a forest of trees if you consider each post that is not a ...


-2

If you want a website based on excel data with basic filtering or visualizations, that is office 365. You can have multiple people viewing read only versions. You can probably make due with Excel for quite a while, especially if you can simply start a new file every few months. If you want a real custom web app, you need a database. Excel isn't really a ...


1

Since you mention this in the context of deployments, I understand that those tables contain configuration or master data that make sense only to newer version able to deal with it. One way to solve this challenge, is to foresee in those tables a from_version version id that correspond to the software version from which this data starts to make sense. you ...


1

According to your narrative, you have abstract Contents, which are potentially very different and therefore need be specialised into concrete Articles, Files, etc.... In an OO perspective, the classes would look like: It appears that you want to implement an association between Content and User: The first design uses concrete table inheritance: there is ...


1

Several thoughts: Regarding your question: without looking at your code we can't tell where it wastes time. In general, the path for handling invalid logins should only affect invalid logins, which you don't want to speed up anyway. The valid login path should only be affected by the "login disabled" flag which belongs to the account data, and ...


2

First of all, do not start optimizing your database schema or imaging you can cut corners. Try to come up with more or less normalized form, which corresponds best with your business domain. Mismodelling will backfire later, it's best to try to make the model right from the start. Even such a small detail like email as the "natural primary key" can ...


1

Many-to-many field. I would like to just use plain Foreign keys for my contract recipients, but I am unsure how should I assign multiple users to the same contract? Perhaps I should create a new model ContractRecipient with the user and contract as foreign keys, but that is a many-to-many field also? This many to many relationship is something that actually ...


4

If you already have users and tasks as entities in a relational schema, I think it makes most sense to store the assignments as entities and relations as well. This is pretty straightforward: each task has a list of (potential) assignments each assignment is a set of one of more users (the ones who carry out the tasl together. For example, your first ...


-3

You have a million copies of the latest Harry Potter book. Does it seem at all reasonable to have a million rows in the database? You’d have one table with book ids, authors and titles (which is probably not enough to uniquely identify a book). And the you have a second table where each row contains an id for the row, and a book Id and an amount of books. ...


21

It depends on the identity of your items: In a book store, books having the same title and same author all look identical and interchangeable. You would have one instance, holding the total quantity. In a second-hand book store, books having the same title and the same author do not look identical: each has a different origin, is more or less used state, ...


1

It depends on what are you going to do with it. If every entity needs to be distinguished from the others or needs to have its own history, then every entity should be represented by a separate record in the database, and the amount should not be its attribute. Examples: You are renting cars, or books, or you are selling tickets for flights and every ticket ...


99

This is not a question of "good practice", but a question of the requirements of the system. For example: Let's say your system is for a library. If the library has several instances of the same book, each copy will have a individual library id and individual attributes like its age, who borrowed it at what date, which condition the copy has, and ...


2

First of all, avoiding NULL values for foreign keys seems like an arbitrary goal. If you follow it through to the extreme, it may lead you to complicated solution without bringing much value. The other point is that it's often best to keep any role-specific data out of the User data. Users of your system may have account names and passwords, possibly real-...


Top 50 recent answers are included