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

5
votes
3answers
199 views

SQL - Algorithm for finding availability of a resource

I'm having trouble creating a mysql compatible algorithm for this. Background App with mysql, perl and JS. It's a booking system where each booking is comprised of a start, end and qty. Start and ...
0
votes
0answers
21 views

Preserving Pre-formatted Multi-Line Strings in Node.js Scripts

There is a lot I don't like about PHP, but one thing I love is multi-line strings: $query = <<<EOT select field1 ,field2 ,field3 from tableName where field1 = 123 EOT; ...
-4
votes
0answers
63 views

Query result with 6000+ columns in a single row [on hold]

There is a business need to fetch about 6000 columns of data from 20+ different tables. This 6000 columns will be served to a database application for further processing. Which databases can provide ...
-1
votes
1answer
67 views

Mono and entity framework, which database to use? [closed]

I was looking into monoproject website, and I saw they have entity framework support. Source: http://www.mono-project.com/docs/about-mono/compatibility/ But my question is: Is it supposed to be used ...
1
vote
0answers
132 views

What is the “correct” way to store functions in a database?

Note: Yes, I know that storing functions in databases should be punishable by law. We are developing a financial web application using PostgreSQL, Sinatra and AngularJS. As you may have guessed, a ...
3
votes
2answers
61 views

Integration tests of SQL logic

In my daily work, I use a lot of SQL logic (oracle stored procedures and SQL functions). To limit the code regression on the implemented code I make what I call "integration scripts" : C# scripts that ...
3
votes
2answers
76 views

Use of NOLOCK on Microsoft SQL Server

The (NOLOCK) optimizer hint is well known by most SQL developers for setting the isolation level so that tables with rows or escalated page locks can be read. I've always known about the bad and ugly; ...
3
votes
1answer
201 views

Is a series of OR or a single IN SQL statement better?

I'm using MS SQL 2008 R2. I have been using a series of OR and have an issue where my app periodically give the following error: Exception message: Timeout expired. The timeout period elapsed prior ...
-1
votes
0answers
17 views

SQL divide two columns [migrated]

Let the following cinema database where a user may critic a movie and assign a score from 0 to 10 to his critic : MOVIE (idMovie) PK (idMovie) CRITICS (idMovie, user, score) PK (idMovie, user) ...
-1
votes
0answers
23 views

Which is better(in terms of seed) xml or sql tables for storing large amounts of realated data? [duplicate]

I am new to sql (and also to this site). Recently i learned about xml and that it can be used to store data. Xml looks much better in the way it presents the data. Now, if i want to make a website ...
1
vote
2answers
111 views

How should I compare two database tables - with SQL or using Java? [closed]

I have two tables with different structure. I should compare ID from 1st table with ID of the intermediate table and then comapre TXT field of the intermediate table with TXT field of the 2nd table. ...
0
votes
0answers
46 views

How can I fix RptViewer timeout for an ssrs report in vb.net applications? [migrated]

I have been developing a couple dozen reports within an application for a client over the last several months and initially had to fight with the report timeouts in the server, sql, and client in ...
3
votes
2answers
159 views

Software development - The industry & general trends / Bad practices [duplicate]

I am a Web Developer and part of a small team working on an abundance of projects. This is my first "actual" real company after graduating with a degree in computer Science and I have about 2 years ...
0
votes
1answer
29 views

Merging user activities into one stream with a common representation

My social network website currently has forum threads and posts gallery pictures albums on the users' profiles group discussions classifieds I would like to create one "stream" of activity. It ...
3
votes
2answers
1k views

One of my team members committed SQL injection-vulnerable code; should I report it to the manager? [closed]

One of my team members committed a huge mistake; a clear SQL injection-vulnerability. It obviously didn't pass my peer review and I made very clear that this is unacceptable. I never saw this ...
0
votes
3answers
241 views

Using SQL queries in loops

Is it a bad idea? I need to compare each entry.Key value in a Dictionary of strings to a SQL table. If there is a match, then I pull the data from that row. I was originally going to use a foreach ...
32
votes
10answers
3k views

Is there any material difference between queries joined by WHERE clauses, and queries using an actual JOIN?

In Learn SQL the Hard Way (exercise six), the author presents the following query: SELECT pet.id, pet.name, pet.age, pet.dead FROM pet, person_pet, person WHERE pet.id = person_pet.pet_id ...
-1
votes
2answers
105 views

Storing Dates & Times in SQL [closed]

I have a tool that I am working on which allows people to create meetings. They can select the Date, Time & Timezone that this meeting is occurring in. I need to determine the best way to store ...
2
votes
1answer
153 views

Should I use foreign keys in my database if I use laravel?

I'm creating a website with Laravel for the first time. I checked relationships documentation today and it seems that Laravel just uses simple SQL queries. class User extends Eloquent { public ...
3
votes
3answers
361 views

What kind of user info is ok to be stored as plain text in SQL Database?

I'm practicing around building e-commerce asp.net applications that allows for users to register to the site and their user credentials are stored in a MySQL database. In my sample project the ...
0
votes
2answers
362 views

Clients connect to WCF or SQL Server

I was wondering what is the prefered way of accessing data from a server in a client application. The data will be stored on the server in an SQL database and I have previously used the following 2 ...
1
vote
1answer
104 views

Implementing “Trending Items” using linear regression in SQL Server

I'm building an MVC .NET website where people can rate and review movies (similar to IMDb). I'm using SQL Server for the back-end. I'll be implementing a feature where the homepage displays trending ...
0
votes
2answers
79 views

Sending a notification to each participant 3 hours before the meeting starts

Let's assume an application that deals with meetings where some users will participate. What is an efficient way to achieve this use case: 3 hours before the meeting should start, one reminder mail ...
3
votes
1answer
133 views

What is the best way to format complex SQL queries in Node?

I am using node-mysql to query a MySQL database via Express and Node. My queries are getting fairly complex and I want to format them across multiple lines. However, the only way I could accomplish ...
10
votes
4answers
792 views

Historical precedent for why Prolog is less popular than SQL in Imperative Programming? [closed]

It seems that writing Declarative SQL is very popular in Imperative Programming. However, it also seems that writing Declarative Prolog could save a lot of complexity but this is not very common. ...
3
votes
3answers
345 views

ASP.NET MVC should I reference the DAL from the UI?

I am developing an ASP.NET MVC application, and I have three projects: UI (with the system.web.mvc reference, BL and DAL references) BL (business facade and business objects) DAL (contains my ...
0
votes
1answer
40 views

Django Project Logic Solution

I'm starting to develop my first webapp, and I'm using django. Before anything I'm working on the software logic, how it should work, the links and objects it needs. The problem is: I need the app ...
2
votes
5answers
189 views

Stored Procedures, ORMs and other application layers

I'm just starting out on a project to develop a new, fairly substantial web application which has an underlying MSSQL database. We're hiring a team of developers to write the application (in .NET) and ...
2
votes
2answers
195 views

An algorithm that spreads similar items across a list

I need an algorithm that distributes same items across a list, so maximizing the distance between occurrences. E.g. I have a list of 15 items: {a,b,c,c,c,d,e,f,f,f,g,h,h,i,j} The algorithm should ...
31
votes
3answers
1k views

Why is most SQL written in YELLING? [duplicate]

On MySQL at least, the following two queries are functionally identical: select * from users limit 0, 1000; SELECT * FROM users LIMIT 0, 1000; However, most example sites and most developers I've ...
0
votes
2answers
58 views

Efficient database access for related data

As an example for this question, consider a content management system that has a content database table which contains things like the page title and location as well as the content itself which could ...
1
vote
3answers
279 views

Best OOP pattern to use for creating a commandline SQL API for a proprietary json based company datastore

We need to create a SQL commandline tool for querying a proprietary json based datastore. I'll be using java. Any suggestions on the primary OOP design pattern I should use for building this API? ...
-1
votes
1answer
407 views

SQLDatabase: Read a lot of data at once and process in memory or read the data when I need it?

I'm not sure how to approach this problem. I require a big chunk of data records from the SQL server. This chunk is based on variables, so I don't know before what records I need. I need to do a large ...
1
vote
1answer
96 views

Database choice [closed]

I am working on a system where I am replacing and existing Cobol system with C#. For the database I have hit some requirement which I am having a hard time to find complete support for (tried SQLite ...
3
votes
3answers
220 views

Is there a 'standard' SQL that can replace all the various custom versions?

I have been writing SQL for over 10 years now. I am extremely proficient at it and have experience working in SQL Server, Oracle, MySQL, PostgreSQL, etc. While there are multiple standards out there, ...
2
votes
2answers
130 views

Combine union with distinct

Situation: I need distinct results from two tables, that both have duplicates. I would like to know if I should combine UNION and DISTINCT. Example 1 - Only use distinct SELECT DistinctValue FROM ...
15
votes
4answers
4k views

Databases: Where should the application logic run? [duplicate]

http://highscalability.com/blog/2010/11/9/facebook-uses-non-stored-procedures-to-update-social-graphs.html talks about how Facebook moved logic out of the database into the application in order to ...
4
votes
4answers
375 views

Organise C++ classes around SQL database

My question is about how best to organize C++ classes around a database model, and I understand this may appear very elementary. The software I propose to create will do the following. It is intended ...
0
votes
0answers
58 views

An algorithm to implement SQL's ORDER BY with TOP/LIMIT or OFFSET/FETCH

Is there a general algorithm to implement SQL's ORDER BY with OFFSET/LIMIT more efficiently than sorting all the records? The algorithm for a simple TOP x is easy enough. It takes one full pass ...
1
vote
0answers
222 views

Separation of concerns between repository and service in DDD with complex entities

This probably seems as an example of opinion-based question, but I'm actually looking for rationale on how to decide correctly, I believe there is a correct solution that can be backed by solid ...
3
votes
2answers
272 views

Does ODBC require any run-time software beyond an .exe file to run against MySQL and ORACLE SQL? [closed]

I'm writing a software [under Windows] in C++ which later needs to be able to connect to both MySQL and ORACLE SQL. Now the software needs to be as simple for the user as possible. Now I'm ...
0
votes
0answers
46 views

Database conceptual Question [duplicate]

When querying in database through PHP, is it good to open mysql connection before every query and close it as the query completes? or should we open the mysql connection as soon as the first query ...
0
votes
0answers
59 views

embedding LEFT OUTER JOIN within INNER JOIN

I am having some problems with one of the question's answered in the book "SQL FOR MERE MORTALS". Here is the problem statement Here is the Database Structure Here is the answer which I am ...
0
votes
2answers
149 views

Is it a bad practice to keep database schema scripts (DDL) and manipulation (DML) scripts in different modules

we have a project structure like the following "module-shared" module depends on "module-database" module and some other modules depend on "module-shared" but no other module depends on ...
4
votes
2answers
300 views

Entity Framework with no direct table access

There are some similar questions I've found here, but none of them fully answer the question I'm asking. Similar questions: here and here In my company, I develop C# .NET applications and our Server ...
1
vote
1answer
275 views

Should ORM data access methods be wrapped or used directly?

We're using an internally-built ORM. Each table is represented by a Model class, which inherits from a base model class that has a handful of methods like GetAll, GetWhere (to get rows with specified ...
-4
votes
1answer
95 views

what data storage method should I use? [closed]

I am currently writing a program and among other things need to store data. The program listens to two computers talking to each other in a known protocol (the program know what protocol it is,the ...
0
votes
2answers
59 views

Changing an int to be a string in PHP / MySQL Schema

Background I'm trying to decide the best way to manage a change in requirements. Currently when an admin is assigned to a ticket, the ticket header record is given an owner and the ownerID field is ...
-1
votes
3answers
231 views

What constitutes a good Database System(Java / SQL related) [closed]

I've given this so much research but still couldn't come to my own conclusion, before continuing this question I would like to give you a rough idea of my current situation. I'm 18 years old and have ...
3
votes
2answers
97 views

An algorithm for finding subset matching criteria?

I recently came up with a problem which I would like to share some thoughts about with someone on this forum. This relates to finding a subset. In reality it is more complicated, but I tried to ...