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

6
votes
2answers
993 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 ...
16
votes
9answers
4k views

Whether to put the business logic in Stored Procedure or Not?

There is always a debate over the topic - "Whether to put the business logic in Stored Procedure or Not?". If we decide not to use the ORM Tool and not to put the Business Logic in Stored Procedure ...
47
votes
14answers
3k views

Is SQL important if I know ORM frameworks well? [closed]

I don't have any serious experience in SQL and I even hate to write SQL instead of LINQ. I am happy enough with ORMs. From the employers and sector view point, is it important to know SQL? Do I have ...
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 ...
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 ...
3
votes
3answers
428 views

Why should I add CHECK CONSTRAINT?

Following is a table creating script created by Entity Framework using the model shown in http://codereview.stackexchange.com/questions/14077/is-it-proper-tpt-inheritance. In this script, there are ...
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
468 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
152 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
3k 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
322 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 ...
14
votes
5answers
1k views

Why is filesystem preferred for logs instead of RDBMS?

Question should be clear from its title. For example Apache saves its access and error logs in files instead of RDBMS no matter on how large or small scale it is being utilized. For RDMS we just have ...
17
votes
2answers
6k views

self referencing tables, good or bad?

Representing geographical locations within an application, the design of the underlying data model suggests two clear options (or maybe more?). One table with a self referencing parent_id column uk - ...
2
votes
0answers
468 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 ...
12
votes
3answers
692 views

Is reliance on parametrized queries the only way to protect against SQL injection?

All I have seen on SQL injection attacks seems to suggest that parametrized queries, particularly ones in stored procedures, are the only way to protect against such attacks. While I was working (back ...
5
votes
5answers
2k views

Two database fields for date and time - should they be merged?

In the following question, field and table names have been changed to protect their identities. If I have two database columns: MONKEY_DATE DATETIME NULL (with data e.g. 2012-05-14 00:00:00.000) ...
1
vote
1answer
213 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
126 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 ...
18
votes
9answers
2k views

Should a primary key be immutable?

A recent question on stackoverflow provoked a discussion about the immutability of primary keys. I had thought that it was a kind of rule that primary keys should be immutable. If there is a chance ...
5
votes
1answer
762 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
69 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 ...
8
votes
3answers
2k views

Storing n-gram data

(hopefully I landed on the right stack exchange site) I was hoping to brainstorm a little bit on the subject of storing n-gram data. In my project, I am trying to solve linguistic problems where I ...
1
vote
1answer
204 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 ...
4
votes
1answer
400 views

Designing a universal database driver class

I have a homebrew MVC framework that I have been using for a while, and it has been working great, but I am planning an upgrade to it for its ORM classes. So far, it only supports SQL databases by ...
1
vote
3answers
356 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
4answers
227 views

Create a database for database tables

I'm working on a project where I have to give users the ability to build their own tables, each user can create more than one table. (the type of all data is string). The user can create a table and ...
0
votes
1answer
360 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 ...
0
votes
0answers
55 views

Document existing Visual Studio Project [duplicate]

I am a small business owner and my sole developer quit. Cold. I am not a coder. He developed an existing application that works .net, c#, javascript, sql, visual studio based, 250,000 lines of code. ...
3
votes
6answers
1k views

OOP (php) for beginners - some unclarities

I started reading some tutorials about OOP, because I want to learn the basics. I have a question about it. I understand how you can have a object "Car" and give it a color like this ...
0
votes
2answers
200 views

Should I retrieve one large set of data to filter or smaller individual sets of data?

I have a company intranet that utilizes a similar set of data across many different pages and many different methods. Speaking in generalities, is it closer to "best practice" to retrieve a large ...
1
vote
2answers
633 views

Registration: Email hash and verifying only one account per email

I'm using a registration function that hashes the email in PBKDF2 with a random and unique Salt each time. The hashes email and his salt are saved in the DB. No problem with that. The problem is that ...
0
votes
1answer
3k views

Best place to write SQL queries

I've been working on this project for my company. Currently I am embedding my SQL statements inside the program itself as and when they are needed. I do have two seperate classes - QueryBuilder ...
1
vote
1answer
118 views

Visual Studio DBProjects and problem with it running post-build SQL (file too big)

What I am doing is creating a DBProject.. importing a DB.. then creating scripts in the PostBuild that are DATA scripts for each table (so that the post build can populate the tables after the schema ...
2
votes
2answers
354 views

Best strategy in SQL

Recently, a colleague told me that it wasn't advisable to make conditions in the join clauses. Instead he suggested to make conditions in the where clause. He told me that the SQL engine was optimized ...
0
votes
2answers
218 views

ACID compliant Database that isn't NoSQL? [closed]

I'm not necessarily asking if a NoSQL database can be ACID compliant, which has been asked here: Is there any NoSQL that is ACID compliant? I'm wondering if we have a database either now or in the ...
1
vote
2answers
218 views

Are error codes wrong in SQL queries too?

I have an SQL query which does several things at once¹: it does multiple checks and then, if the checks pass, updates some data. Without entering in the domain-specific details, here's an imaginary ...
2
votes
3answers
174 views

Referencing countries via Foreign Key Constraint

To make things simple to explain: I've got two tables: Table1 and Countries. The Countries table contains a nice flag and some information, such as DisplayName, the ISO3166 ALPHA3 code and the phone ...
2
votes
2answers
362 views

Not using SQL Transactions

I am looking at a codebase where a developer never uses SQL transactions i.e. each update/insert into the SQL database is an atomic operation. I believe the codebase would benefit from transactions. ...
0
votes
1answer
763 views

TFS SQL Deployment Data Script

We are using TFS and SQL Server 2005 (looking to upgrade to SQL Server 2012 if that makes a difference). We store our database schema in a Visual Studio Database project (VS 2010). When code is ...
9
votes
4answers
1k views

Will working in IT limit your career prospects as a programmer? [duplicate]

I took a job working as an IT guy (SQL programming, helpdesk, etc.) because I had need of a job (to pay back student loans accumulated from school). I'm very happy to have a job, but I eventually ...
7
votes
4answers
9k views

why are noSQL databases more scalable than SQL? [duplicate]

Recently I read a lot about noSQL DBMSs. I understand CAP theorem, ACID rules, BASE rules and the basic theory. But didn't find any resources on why is noSQL scalable more easily than RDBMS (e.g. in ...
0
votes
3answers
180 views

How to maintain user relationship when user unfollows another user

I have a table of user relationship which stores who follows whom, the table structure is as follows -id -follower -following when someone follows any other user, I add a record with follower user ...
5
votes
1answer
620 views

OpenID implementation - PHP, Javascript, MySQL

I've started doing some research on the technologies that I will need for my website. I'm trying to implement a really simple website with OpenID user registration. The website will store a block of ...
9
votes
4answers
1k views

Why do relational databases only accept SQL queries?

As far as I know, most relational databases do not offer any driver-level API for queries, except a query function which takes an SQL string as an argument. I'm thinking how easier it would be if one ...
3
votes
1answer
937 views

Calling MSSQL stored procedure from Zend Controller ? Any other approaches?

MSSQL and DB, Zend as PHP Framework, I am using this way to call SP with I/P Parameters and to get O/p Parameters. It seems I am writing SQL code in PHP. Any other good approaches? $str1 = ...
1
vote
2answers
455 views

Why OTServs have an item cloning problem if the server crashes? [closed]

OTServs are open source MMORPGs with a huge community. Mostly all of them have a serious problem: if the server crashes, people can clone items. This is a dirty trick that can be executed because the ...
12
votes
6answers
2k views

Do You Still Need Indexing After Database Normalization

After you have done a good normalization, do you still need to index the table? How is this going to affect the performance? Will it even affect the performance in some way after a good normalization? ...