Tag Info

New answers tagged

2

You don't need a class for that, but maybe you want one. At the database design level, I like to avoid linking tables and think of those tables as first class entities instead. So if we have student and class tables for example, instead of creating a student_class linking table to satisfy that many-to-many relationship, we could call it something like ...


1

That is correct. You simply have a property of groups (which makes more sense to me than students, but that's a matter of opinion) that is an enumerable collection of students that belong to the group.


2

Nothing is wrong with this for development. If it has a name, I suppose it would be a mock database. It is not uncommon to create a mock database that can emulate very basic functionality. You have the added advantage that you start from a scratch database each and everytime, thus you know that your program would work also for a potential empty nosql ...


1

Some (much?) data, such as the book example, isn't inherently hierarchical. That the bookstore example uses hierarchical storage is a consequence of XML's tree structure, not the inherent structure of the data. Consider that a book can have many authors, and an author can write many books, which means neither can strictly belong to the other. XML gets around ...


1

Hierarchical databases used to be very popular, but they went out of fashion in the 80s because they are not very good at supporting ad hoc querying, and setting them up could be difficult, I believe. The best known standard for hierarchical databases was the CODASYL data model (see http://en.m.wikipedia.org/wiki/CODASYL for details of this), which was ...


1

If you choose to maintain a hierarchy in a relational database, you need to look into the Nested Set design pattern. (See Wikipedia) This model involves some programming, and it involves some overhead at insert or update time. The benefit comes at retrieval time. Retrieving the path or the subtree for any given node is easy and fast, when compared to the ...


0

I just will save the opearations made by the user and the concerned objects in a Map <String, List<FacturedServices>>. If a user delete a FacturedServices, it will be added to the map with a "DELETE" key. Then I will iterate over the map and execute delete, update or create commands according to keys. A more professional solution would be to ...


0

I would like to offer a different approach than the accepted answer based on event sourcing + cqrs. Event sourcing is a different approach than nor relational design. You basically have only one table lets call it events. An event Is something that happened in the past tense. I.e AccountCreated MoneyDeposited. These events are classes that you serialize to ...


2

My experience in this sort of thing is to prefer to stay consistent within my program. In other words, you feel you can't do without a database, then your program would likely be more robust if it depended only on that database rather than also on the file system. The more components your program depends on, the more problematic it becomes in terms of ...


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 ...


-1

Since the requirements are not clear one can start with a very rudimentary data model with the key elements you will know you need, maybe just basic tables and PKs to start. The rest of the data, serialize to binary or XML and store the BLOB in the database to start with. That should allow one to develop the UI and business layer (middle tier) without a ...


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 ...


0

You may want to consider not using SQL at all, but use something like Azure table storage. Troy Hunt has an interesting article on its performance on huge datasets: http://www.troyhunt.com/2014/12/applied-azure-infographic-of-how-have-i.html


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 ...


1

I worked at a place that had a fair amount of independent data sources. They did put them all into a single database, but into different schemas that were accessed by webservices. The idea was that each service could only access the minimum amount of data they required to perform their work. It wasn't much overhead compared to a monolithic database, but I ...


2

I wholeheartedly agree with btilly's answer, but just wanted to add another positive for Microservices, that I think is an original inspiration behind it. In a Microservices world, services are aligned to domains, and are managed by separate teams (one team may manage multiple services). This means that each team can release services entirely separately and ...


-1

In general i think code comes after data because the code is going to manipulate the data. If requirements are not clear you can create a data model of your interpretation of the requirements. Best is maybe to write down some requirements and send it to your employer, then they have something to shoot at. Or create a gui first, it depend of the type of ...


13

Let's talk positives and negatives of the microservice approach. First negatives. When you create microservices, you're adding inherent complexity in your code. You're adding overhead. You're making it harder to replicate the environment (eg for developers). You're making debugging intermittent problems harder. Let me illustrate a real downside. ...


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 ...


8

I was going to say Database First since I have a lot of experience with large projects and you really need a solid data model if you have many developers working in parallel. But then I though about it a little more and I realized that what we were really doing on the more successful large projects was "requirements first". A good well specified set of ...


4

My experience is as follows: In most projects I've worked on, we design the database first. Often times data already exist in spreadsheets, legacy databases, paper, etc. That data will hint you about the tables you need to hole it. Often times a process is already being use, yet manually or using several, disparate tools that are not automated, don't ...


62

What came first, the process, or the data used by that process? I know this is kind of a "chicken or the egg" question, but in the case of software, I believe it is the process. For instance, you can build up your data model incrementally by implementing a single use-case at a time with just in-memory persistence (or anything as easy to implement). When you ...


7

Since this seems so fluid/unspecified, I'd do the frontend GUI first - that sounds like what you need to get responses, support, time, and feedback from the stakeholders, right? They don't care about your brilliant normalized tables and foreign keys constraints and cascading deletes. But a cool GUI with lots of shiny colors - well, that's top notch! For ...


12

A root cause analysis suggests this problem is not one of method, but is the lack of a specification. Without one it doesn't really matter what you write first - you are going to throw it away anyway. Do yourself a favour and do some basic systems analysis - identify some users at various levels, make up a quick & dirty questionnaire then turn off your ...


-1

Another option is to use a database that natively supports inheritance, e.g. PostgreSQL.


2

Follow composition over inheritance as composition lends itself well to relational databases. Say you want to get all short messages: SELECT * FROM Message INNER JOIN ShortMessage ON ShortMessage.message = Message.id Say you want to get all short messages and emails: SELECT * FROM Message LEFT OUTER JOIN ShortMessage ON ShortMessage.message = ...



Top 50 recent answers are included