Structured Query Language (SQL) is a language for managing data in relational database management systems. This tag is for general SQL programming questions; it is not for Microsoft SQL Server (for this, use the sql-server tag), nor does it refer to specific dialects of SQL on its own.

learn more… | top users | synonyms

0
votes
1answer
66 views

Relationship between REST APIs and Databases

I've been studying databases and rest APIs lately and I have a question about the relationship between the two. Imagine I have a database with three tables, STUDENTS, ENROLLED, and CLASSES. STUDENTS ...
0
votes
0answers
21 views

Recommendations for Big Data filter/formula language [closed]

I'm working on a project which deals with terabytes of logging data which all must be preserved in it's original state. On top of this, to make it meaningful to the end user, it needs to have VERY ...
0
votes
0answers
31 views

Best practices for dashboard of near real-time analytics

I’m currently building a dashboard to view some analytics about the data generated by my company's product. We use MySQL as our database. The SQL queries to generate the analytics from the raw live ...
8
votes
4answers
439 views

Is a 25+ table join a code smell all by itself? [closed]

I just think our database design is terrible. Academically it's great! It's in like 85th normal form. Practically, this results in some queries with so many tables, it's basically impossible for a ...
2
votes
4answers
67 views

Keeping a ratio column that's the division between two other columns

I'm about to build a SQL table where I want to store currency orders. That means that I need to store how much I paid for a certain quantity, and the ratio between both quantities. So for example: ...
0
votes
0answers
11 views

SQL data model for nested milestones/timframes

I'm currently weighing different approaches to a data model and I'm curious what others would do. The main nugget of info is ACTIVITIES, which belong to a chain of milestone time releases. Stages ...
0
votes
0answers
49 views

Options for implementing database and programming logic for statistics application?

I am implementing a statistics driven web application. The statistics relate to sporting events. Right now I have a postgresql database with a table that holds a row for each match. This is a ...
-1
votes
1answer
37 views

Querying Results from End of the table

Normal behavior of the SQL Table is to add new rows in end of the table. I want to query results of single row only. So mysql command is SELECT id FROM users WHERE country='india' LIMIT 1 this ...
0
votes
0answers
10 views

When would I choose a Lucene/MSFT Search of SQL to store Spatial data?

I need to store the locations of stores and allow customers to query nearby businesses, with a varying amount of filters. The filters in the Search world seem to be named "facets" What reasoning ...
3
votes
0answers
23 views

Using mysql 5.7 Json Columns for EAV

I am developing an e-commerce product and I have been able to implement all functionality and am left with allowing users to create additional attributes for a product. Right Now I have two options. ...
0
votes
0answers
95 views

Advice on program performance after changes

So, the situation is like this: For the past two years, I have implemented a class in c# which is used to filter different fields from different tables in database (SQL), for reporting purposes. Now ...
0
votes
0answers
29 views

Use vb.net sql reader as a Delegate to gather Data

Is there a way to use a sub to create a loop, but change the content of the inside of the loop? I don't know what I don't know. I keep looking at this code and I have a feeling that it's possible. ...
-1
votes
0answers
19 views

Store SQL queries in the database or in the server script? [duplicate]

I used to do queries from PHP by manually making a query string like "SELECT * FROM ... WHERE ... AND ...", but my office does it by making stored procedures in the database and just querying "CALL ...
0
votes
0answers
19 views

Better way to build SQL query from form input? [migrated]

Very new to php. Using XAMPP, netbeans. I am using a <form> to send various input parameters as a GET to retrieve data from a very simple two table MySQL db. After filtering the inputs ...
0
votes
1answer
58 views

Designing Pricing table in MYSQL

I'm designing a pricelist table for my database. It will include Customer, Model, Start_date, End_date, Price, Currency, RRP When I update a new pricelist which is sent every now and then (maybe ...
41
votes
8answers
5k views

Isn't the use of NoSQL Databases impractical in a large number of use cases? [closed]

I've been learning about NoSQL Databases for a week now. I really understand the advantages of NoSQL Databases and the many use cases they are great for. But often people write their articles as if ...
2
votes
0answers
81 views

Why isn't LIMIT [offset,]row_count in standard SQL? [closed]

SQL:2008 added support for a comparable OFFSET syntax OFFSET num {ROW|ROWS} FETCH {FIRST|NEXT} [num] {ROW|ROWS} ONLY. On the other hand, MySQL (and SQLite) support LIMIT offset, row_count or LIMIT ...
4
votes
2answers
85 views

How to represent a collection with capacity in a database?

Concerning normalization of a one to many relationship, I am not sure how to represent a collection with a specified capacity in a database. I can think of two ways to represent an entity A with a ...
3
votes
3answers
94 views

Relational table design for data ownership

Setup (schema simplified for clarity) Suppose I have a table called resource: +---------------+--------------+------+-----+ | Field | Type | Null | Key | ...
1
vote
1answer
80 views

How to handle multiple “valid after {date}” in a performant way

We work on an Application which displays a duty roster and also some other DateTime related things. So my Database is full of Relations like in this small Example: This results in big ...
0
votes
1answer
71 views

Django Migrations: Binds data to code?

If you have custom code for models (custom validators and custom fields are examples), Django Migrations will import them directly into the migration files. An example: file web/models.py def ...
1
vote
1answer
45 views

MS SQL Server Cell level Encryption options

Recently, i got the task of doing some research into the data encryption at the cell level. I tried using the Symmetric key (by passphrase) & second option i took is Symmetric key (by ...
1
vote
2answers
72 views

Working with local connections instead of global

In recent weeks I became very concerned that the way I've been working with database connections for the past years, is simply wrong. I exclusively create a new connection for each database operation ...
1
vote
4answers
233 views

How to deal with long running transactions?

I'm developing a Content Management System (CMS) and I would like to include a "Save Changes" button. I mean: a user performs several changes in the database, but those changes are still not ...
0
votes
1answer
34 views

Database multiple database query each time

I'm writing a rest service. For each request I use about 4-8 queries. Should I try to refactor those into a single query?
2
votes
3answers
116 views

Long running DB query with concurrent write at the same time [closed]

We have a big table with a lot of data and a select query which takes 3 seconds to run. However we are a highly concurrent environment and each second we get 100 new records in our database. So ...
3
votes
2answers
234 views

Deep SQL relationships to a C# object model

I have a database with deep table to table relationships for example Clients (one to many) -> ClientData (one to many) -> ClientJob (one to many) -> ClientProcess (one to many) -> ...
0
votes
1answer
68 views

SQL Table With A Call To Action?

This is all done in Microsoft Access 2007 and SQL Server. We are creating a way for our users to quickly make notes on a customer. These quick-notes will contain tags that will prompt the user for ...
4
votes
2answers
113 views

Database constraints for a recursive folders structure

In an application, I have a recursive folder structure (like folders in OS X or Windows file system). Each folder can contain three kind of things: Other folders (hence the recursive structure) ...
2
votes
3answers
152 views

automatic database fill up in sql script tests

The problem I am working on an application with ~ 1000 tables in a sql server database. I am having a recurring issue with a sql script. The script is used by the consulting team to "clean" some ...
3
votes
1answer
156 views

How do SQL transactions return immediate results?

I am using transactions to do bulk insert/updates. This is my little test loop: $now = date('Y-m-d H:i:s'); for ($i=0; $i<60; $i++) { $db->insert($cfg['ps_manufacturer'], array( ...
0
votes
3answers
318 views

Why does databases use text? [closed]

This might be a little dumb question but why do we save text in the db instead of something smaller? Couldn't there be some other way to store data in the db like in a compressed form, and then have ...
0
votes
1answer
140 views

What is the problem will happen if I create auto generate ID without using mysql auto increase of mysql table by my self?

I would like to ask you a question about MySQL AUTO_INCREMENT. I already created my own function to generate AUTO_INCREMENT when the user inserts any data input a table in MySQL. This function works ...
6
votes
1answer
386 views

Clean Architecture - How to go from “Database Driven” to “Independent of Database” [closed]

I am looking for some clarity and hopefully some advice on writing clean architecture for a large system. My Companies "Web Solution" is +-10 years old, my job is to rewrite it. It is written across a ...
1
vote
1answer
195 views

Why do I need to use recursion on the classic employee manager database relationship?

Take the data from the Oracle scott database. I have modified it to have multiple levels of management from the original, select * from scott.emp order by mgr desc; empno ename job ...
-1
votes
1answer
84 views

behaviour of SQL BETWEEN operator [closed]

This is kind of philosophical question... Today i spent way too much time to debug a method which was generating a SQL command. I figured out the error was because the code was generating something ...
21
votes
4answers
3k views

Why not just make non-parameterized queries return an error?

SQL injection is a very serious security issue, in large part because it's so easy to get it wrong: the obvious, intuitive way to build a query incorporating user input leaves you vulnerable, and the ...
2
votes
1answer
83 views

Time attendance module design

I am working on time attendance module and I managed to read the data from the timing machine in the following format: Id CheckIn Type Status 0000142 5/15/2015 6:00 PM 2 OK ...
0
votes
1answer
81 views

Optimizing instant notifications

Scenario To deliver instant notifications to the client, I'm sending an AJAX request to a PHP page that checks if there are new notifications: if there are, it outputs them, otherwise it sleeps for ...
1
vote
1answer
111 views

Web framework in pure SQL

I heard that SQL is Turing complete language (for example: http://stackoverflow.com/a/7580013/2604170) I am just curious if would be possible to create independent web framework like Ruby on rails or ...
1
vote
0answers
373 views

Why does convention say DB table names should be singular but RESTful resources plural?

It's a pretty established convention that database table names, in SQL at least, should be singular. SELECT * FROM user; See this question and discussion. It's also a pretty established convention ...
2
votes
1answer
367 views

What is the best way to store a formula in a database for a table driven formula? [closed]

So I am changing my code over to a table driven formula system to make it sustainable in the long term. So basically I have 5 foreign keys that will get me to a single formula to use. However I'm ...
1
vote
2answers
108 views

Partial Update of Database Table

I have a database table with numerous fields including "category". The source of this table is an xml file which the system receiving occasionally. Each xml file contains data for one category. The ...
2
votes
1answer
90 views

Best practices for scope of returned data per stored procedure

I have the following situation: table1 ------------ ID Name Param1 Param2 Param3 RegistrationID 1 Test Value1 Value2 Value3 101 table2 ------------ RegistrationID LangID Value 101 ...
1
vote
1answer
95 views

Is it a good practice to write distinct queries in a single stored procedure based on input parameters

I am going through the stored procedures written throughout our project and see that multiple distinct queries are written inside a single stored procedure and are called by passing different values ...
1
vote
1answer
134 views

What's the quickest and most maintainable way to implement SQL querying of disparate C++ variables?

I've recently joined a team working on radar observations. The team has access to a repository of software (written in C++) used for dealing with these observations, but their work is focused towards ...
2
votes
3answers
184 views

At which point using string-based enums can become a real problem?

This is a direct follower to this question. An answer given to that questions says (my understanding), that nowadays using string-based enums instead of integers isn't a much problem, because hosting ...
1
vote
0answers
33 views

Adding fields a good use case for EAV? [duplicate]

Is being able to add fields quickly to a system a good use case for EAV? What would be the frequency or number that would justify using an EAV model?
3
votes
6answers
4k views

What is faster? Using REST API or querying a database directly?

What is faster performance wise? Creating a REST API and having your web app use the REST API to do all interactions with your database OR querying your database directly (i.e. using whatever typical ...
4
votes
2answers
180 views

Are (basic) SQL queries semantically equivalent to Higher Order Functions?

Is SQL basically a domain specific instance of map + fold + filter? It seems to me that the following SQL: SELECT name FROM fruits WHERE calories < 100 is just syntactic sugar for the ...