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
87 views

Multiple schemas vs aditional column per customer

If you have different database per customer as there is no need to share any data between them does the same apply if a customer has multiple stores ? I believe that it is easier to do queries for ...
0
votes
1answer
608 views

Notify client about changes in database in java

I've been searching around for the answer to this question, but haven't been able to find a solution. I am working on a distributed client-server system that uses TCP. The program's functions is to ...
0
votes
1answer
94 views

SQL-99 specification, is it specified to first order the result and limit it afterwards?

If I wrote this in MySQL SELECT * FROM foo ORDER BY bar LIMIT 1 it would first order the result and limit it afterwards. I always get the lowest bar. I wonder if this is specified like this in ...
7
votes
1answer
240 views

Can relational algebra/calculus proofs be used to test/verify SQL?

Is it feasible or even possible to use relational algebra and/or relational calculus in the form of proofs to test/verify the correctness of SQL statements, functions, and stored procedures? It seems ...
7
votes
5answers
310 views

In retrospect, has it been a good idea to use three-valued logic for SQL NULL comparisons?

In SQL, NULL means "unknown value". Thus, every comparison with NULL yields NULL (unknown) rather than TRUE or FALSE. From a conceptional point of view, this three-valued logic makes sense. From a ...
3
votes
1answer
185 views

Best way to rename existing unique field names in database?

I have a database table that contains id, filename, userId id is unique identifier filename should also be unique table may contain >10000 records When a user uploads a file it should be ...
2
votes
2answers
1k views

Database model for keeping track of likes/shares/comments on blog posts over time

My goal is to keep track of the popular posts on different blog sites based on social network activity at any given time. The goal is not to simply get the most popular now, but instead find posts ...
1
vote
1answer
182 views

Store data for multiple User Type

I am developing an app where four types of user share same module. So is it a good idea to create: one table and user_type and user_id (something like that) table prefixes basically 4 diff tables of ...
1
vote
2answers
128 views

Configurable tables in sql database

I have the following tables in my database: Config Table: ====================================== Start_Range | End Range | Config_id 10 | 15 | 1 ...
7
votes
1answer
1k views

Is inline SQL still classed as bad practice now that we have Micro ORMs?

This is a bit of an open ended question but I wanted some opinions, as I grew up in a world where inline SQL scripts were the norm, then we were all made very aware of SQL injection based issues, and ...
0
votes
2answers
2k views

Using lucene and sql server togheter. Newbie needs directions [closed]

Basically the whole thing can be explained simply: I need to index one or more SQL Server 2005 databases with lucene so I can search the various records. I found a lot of examples and documentation ...
1
vote
1answer
124 views

structure problem in Relational DBMS creation

For learning and understanding purpose, I currently want to try to make a small relational DBMS with simple features like (for now) only sequential reading/writing and CREATE TABLE, INSERT, SELECT, ...
12
votes
2answers
2k views

SQLite with two python processes accessing it: one reading, one writing

I'm developing a small system with two components: one polls data from an internet resource and translates it into sql data to persist it locally; the second one reads that sql data from the local ...
2
votes
4answers
844 views

Database is performing slow, even all the tables are having normalization

One of the interviewers asked me this question: Tables are created with appropriate normalization rules, However the database is performing slow. [Ie.: The select, insert statements are taking ...
0
votes
1answer
761 views

C# Design for SQL connection and commands

Currently I'm working on system that works with database, and I would like to have it done elegant way. So I have abstracted DBConnection into one class, DBCommands into another class. (DBCommands : ...
-1
votes
2answers
565 views

SQL API instead of a REST API? [closed]

What are the pros and cons of exposing an SQL API instead of a REST API? Let's assume that this would be a private API – the API developer and user are on the same team. Probably the biggest problem ...
10
votes
7answers
386 views

Nested Entities and calculation on leaf entity property - SQL or NoSQL approach

I am working on a hobby project called Menu/Recipe Management. This is how my entities and their relations look like. A Nutrient has properties Code and Value An Ingredient has a collection of ...
17
votes
4answers
2k views

Why many designs ignore normalization in RDBMS?

I got to see many designs that normalization wasn't the first consideration in decision making phase. In many cases those designs included more than 30 columns, and the main approach was "to put ...
-1
votes
3answers
351 views

What would be a good “umbrella” term for HTML, CSS, SQL, JavaScript and the like? [closed]

There appears to be a pretty clear consensus on the question about whether HTML and CSS are programming languages. They are not. HTML is a markup language and CSS is a stylesheet language. You could ...
3
votes
2answers
859 views

Best practice in application design / SQL authentication

I am currently involved in the implementation/design of an existing application for a large scale customer. The application has a similar model as e.g. vCenter Server whereby a number of components ...
1
vote
2answers
2k views

Using Autoincrement Primary keys as Foreign Keys

When creating a table, there is an option for us to set the numeric primary key as autoincrement where it's value increases whenever a new data in inserted. This primary number can be used for ...
6
votes
8answers
2k views

Why can't SQL return joined tables in a nested format?

For example, say I want to fetch a User and all of his phone numbers and email addresses. The phone numbers and emails are stored in separate tables, 1-user to many phones/emails. I can do this quite ...
0
votes
2answers
211 views

Automating database deployment using a CMS

My team are developing Umbraco websites and looking to improve the automation of our database deployment. Currently we have automated builds and deployments of our source code using Kiln and Team ...
0
votes
2answers
206 views

Best practices for rotating large datasets?

[edit]Turns out there's 1.5 million records... The SQL database is taking about 17-20 seconds to run the query. Would it be best to have Java handle the joins and rearranging in that case? Since this ...
1
vote
1answer
159 views

What's the best approach to building a db schema for profile, but to track changes?

I'm working on a site where companies can create a profile then add locations for each profile. Those first two tables are simple enough. But any changes to their profiles or locations have to go ...
4
votes
2answers
864 views

Logic design question for SQL query

Was wondering if you could help me on a SQL problem I’m having. I have a set of records of events where each event has a start time and end time. No event has the same start time, and the end time ...
3
votes
5answers
1k views

Is SQLite a sensible option for data logging?

I am trying to setup a small data-logging application under linux. The data arrives via serial port, and from there it should be pumped to logging and to graphical display. The logging functionality ...
2
votes
1answer
578 views

Status update & news feed database design / architecture

Imagine a application similar to Facebook, where you have status updates and a news feed. The names and profile pictures can be changed. There are also several different types of updates requiring a ...
0
votes
1answer
294 views

Different ways to generate the latest int type primary foreign key in code

I am new to sql. I have added 2 new tables in database. The primary key of first is a foreign key in the other. The type of the keys is integer. Now I want to generate the keys in the code and assign ...
6
votes
2answers
1k views

In what order are rows fetched absent ORDER BY clause?

One programmer is testing and comparing the same application which uses the same database structure, and the same data, only in two separate databases, one with Oracle 8 and one with Oracle 9. The ...
0
votes
1answer
403 views

Are there any SQL servers that support compiled queries?

Can SQL queries be compiled into byte code or equivalent to enhance performance? I know that most database servers support prepared statements, but is that the same thing as compiling? Most ...
3
votes
1answer
2k views

JOIN vs. INNER JOIN and FULL OUTER JOIN

I know there is a difference between INNER JOIN and FULL OUTER JOIN, I can see it, but, what is the difference between the two following: JOIN ... ON... and INNER JOIN...ON... and still yet ...
19
votes
2answers
3k views

SQL IN() versus OR

I was working with a query I wrote today had to change the code from the WHERE clause to use a IN(list of stuff) filter instead of using something like item_desc = 'item 1' OR item_desc = 'item 2' OR ...
3
votes
1answer
475 views

Rewriting C# Formula Calculations in T-SQL

We have a 3-tier application with a C# client that connects to a C# web service via WCF and requests data from a SQL Server database. One feature in our application is a user-created form app in ...
3
votes
5answers
325 views

Need thoughts on a course curriculum for an entry-level programmer [closed]

Would love to know your thoughts on a curriculum that will be developed for people that want to get started in the programming field. The goal of the course is to help it's students to ensure that ...
1
vote
1answer
153 views

What is better: multiple sql entries or one sql entry with a list field?

Suppose that I have the following logical information: (tag_name, id). For example: (food, 1),(food, 2),(food, 3),(drink, 1),(drink, 2) I'm trying to decide what is the best way to store it in a ...
0
votes
2answers
75 views

Working with data and meta data that are separated on different servers

While developing a product, I've come across a situation where my group wants to store meta data for data entry forms (questions, layout, etc) in a different database then the database where the ...
6
votes
4answers
4k views

C# Minimal SQL Database

I'm working on a small project (not production) where I'm needing to store enough data that something like a CSV would be inefficient to process and an SQL/MySQL server would be too much. Does .Net ...
0
votes
1answer
341 views

Advanced Search Stored procedure

So I am working on an MVC ASP.NET web application which centers around lots of data and data manipulation. PROBLEM OVERVIEW: We have an advanced search with 25 different filter criteria. I am using a ...
11
votes
5answers
2k views

At what size of data does it become beneficial to move from SQL to NoSQL?

As a relational database programmer (most of the time), I read articles about how relational databases don't scale, and NoSQL solutions such as MongoDB do. As most of the databases I have developed ...
2
votes
0answers
475 views

Clustering Strings on the basis of Common Substrings

I have around 10000+ strings and have to identify and group all the strings which looks similar(I base the similarity on the number of common words between any two give strings). The more number of ...
1
vote
1answer
225 views

Formatting SQL statements [duplicate]

In recent years I've developed a habit of formatting SQL SELECT queries like so: SELECT fieldNames FROM sources JOIN tableSource ON col1 = col2 JOIN ( SELECT ...
2
votes
1answer
131 views

Testing MVC models when using SQL referential constraints

I have an MVC web app that's wired against PostgreSQL. The DB uses the full gamut of various referential constraints to ensure referential integrity, as opposed to say the Rails approach, where you ...
5
votes
1answer
829 views

Is SQL declarative?

I ask because so many of the questions I see in SQL amount to: "This is slow. How do I speed it up"? Or are tutorials stating "Do this this way and not that way as it's faster". It seems to me that a ...
1
vote
1answer
70 views

SQL Table Design Modification based on data roles or implementation convenience?

I've got an existing SQL table structure that looks like this: Orders - order_id - organisation_id - [all the rest of the order data] Organisations - organisation_id - [all the rest of the ...
1
vote
1answer
213 views

How can I maintain a SQL schema upgrade that goes out to our users on a regular basis?

I work on a project that uses a SQL database as a back end, and a desktop app as a front end. We do releases on a regular basis, and as part of a release, our client needs to update their SQL server. ...
3
votes
2answers
1k views

Saving user profiles in SQL database

So, I got a table UserProfiles in my database, that, similar to C#'s Settings file, holds a property with the appropriate datatype and the specified setting in the profile. Now each time I add a new ...
1
vote
3answers
382 views

Protect Database Design - SQL

Perhaps a bit of an odd question but I can't think of a way to achieve what I want. I produce a product which ends up installed on-site at clients premises. It is a business critical and high ...
0
votes
1answer
378 views

What is the proper and easy way to move a LocalDB to Azure using code first ?

The only way I could figure how to do it was create the schema on the localDB with code first and then manually change the database string to Azure and then run the code on Azure.. But that only ...
2
votes
4answers
433 views

How to genericize foreign key references in table?

I am trying to design a table to store references to multiple tables as a "target" of the item in each row. An example should clarify what I am trying to do: Imagine you have 4 tables (images, ...