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
4answers
564 views

Designing a Database Application with OOP

I often develop SQL database applications using Linq, and my methodology is to build model classes to represent each table, and each table that needs inserting or updating gets a Save() method (which ...
3
votes
2answers
490 views

Forced to write Stored Procedures

Can you think of some reasons that the management force the developers to write and call Stored Procedures instead of inline SQL statements directly? Even a very simple CRUD statement, writing a ...
2
votes
3answers
614 views

How To Start Programming [closed]

I have taken a programming course 2 years ago but I haven't worked in programming since then. I recently found a programmer job, but there is no programming team so for me to gain valuable experience ...
7
votes
4answers
2k views

Best C# database communication technique

A few days ago, I read an answer stating that writing queries within your c# code are long gone. I'm not sure what the specific person meant with the comment but, it got me thinking. At the company ...
0
votes
2answers
217 views

Visual C++, CMap object save to blob column

I have a MFC CMap object, each object stores 160K~ entries of long data. I need to store it on Oracle SQL. We decided to save it as a blob. Since we do not want to make additional table, we also ...
3
votes
1answer
971 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
1answer
899 views

How can I implement a database TableView like thing in C++?

How can I implement a TableView like thing in C++? I want to emulating a tiny relation database like thing in C++. I have data tables, and I want to transform it somehow, so I need a TableView like ...
1
vote
5answers
4k views

Externalising SQL Queries in Java

What are the advantages and disadvantages of externalising SQL queries in Java (or similar general-purpose object-oriented programming language. Externalizing means storing all SQL in a separate ...
4
votes
2answers
326 views

Proper Data Structure for Commentable Comments

Been struggling with this on an architectural level. I have an object which can be commented on, let's call it a Post. Every post has a unique ID. Now I want to comment on that Post, and I can use ...
11
votes
4answers
1k views

TDD with SQL and data manipulation functions

While I'm a professional programmer, I've never been formally trained in software engineering. As I'm frequently visiting here and SO, I've noticed a trend for writing unit tests whenever possible ...
4
votes
3answers
702 views

Appropriate use of SQL CLR

We have some back end processes that runs* on our sql server (SQL Server), they involve processing claims. This requires both data manipulation (biz logic) and data read/write to tables. The biz ...
1
vote
2answers
639 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 ...
2
votes
1answer
750 views

Best way to remove list items from an existing record

Ok more of a conceptual question here: Say I have an existing record of type Meeting. When I go to edit the meeting I have a listbox with all current meeting participants, and one with all employees. ...
11
votes
4answers
7k views

Why is SQL's BETWEEN inclusive rather than half-open?

Semi-open (or Half-Open, Half-Closed, Half-Bounded) intervals ([a,b), where xbelongs to the interval iff a <= x < b) are pretty common on programming, as they have many convenient properties. ...
7
votes
2answers
2k views

Best method to implement a filtered search

I would like to ask you, your opinion when it comes to implement a filtered search form. Let's imagine the following case: 1 Big table with lots of columns It might be important to say that this SQL ...
3
votes
3answers
432 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 ...
3
votes
2answers
223 views

Having 2 Initialize Paragraphs in 1 COBOL program

I am designing a COBOL program that does 2 things. 1 reads specific rows from a table, and inserts a new row based on the original. 2 reads different rows from the same table, and updates those rows. ...
1
vote
2answers
111 views

Cataloging events, projects and tasks: Is SQL appropriate?

I have this idea for a database: it would hold everything I "need to remember", and allow future coding projects to access the information. These future projects include a day-planner and historical ...
1
vote
3answers
411 views

Is an API in C++ a better alternative to computing directly in SQL?

I need to perform large amounts of computations on data storerd in a busy Microsoft SQL server. Would it be faster if I retrieve the data from the server, perform the computations locally in C++, and ...
13
votes
3answers
29k views

Why do we need to put N before strings in Microsoft SQL Server?

I'm learning T-SQL. From the examples I've seen, to insert text in a varchar() cell, I can write just the string to insert, but for nvarchar() cells, every example prefix the strings with the letter ...
2
votes
2answers
178 views

Better way to search for text in two columns

Here is the scenario. I am making a custom blogging software for my site. I am implementing a search feature. It's not very sophisticated - basically it just takes the search phrase entered and runs ...
2
votes
8answers
6k views

Is executing SQL through a WebService a really bad idea?

Typically when creating a simple tool or something that has to use a database, I go through the fairly long process of first creating a webservice that connects to a database then creating methods on ...
0
votes
3answers
375 views

Does connection pooling work fine to execute 60 DB queries to load a page?

We use Linq2Sql in an ASP.NET application. Unfortunately the eager-loading in Linq2Sql isn't as powerful as in Entity Framework, so a lot of the data has to be lazy loaded as needed. Taking ...
4
votes
1answer
421 views

What is Rainbow (not the CMS)

I was reading this excellent blog article regarding speeding up the badge page and in the last comment the author waffles (a.k.a Sam Saffron) mentions these tools: dapper and a bunch of custom ...
0
votes
1answer
1k views

Database Driven Web Application, C# Front-End and F# Back-End meaning

Hi I am an intern working with ASP.NET. My current task is to make a website which will incorporate some jquery viewing features. This project seems to me will be primarily dealing with reading data ...
0
votes
3answers
1k views

Is this overkill? Using MDX queries and cubes instead of SQL stored procedures

I am new to Microsoft's SQL Server Analysis Services Cubes and MDX queries. Where I work we have a daily sales table in SQL Server 2005 that already contains an aggregate of sale information per ...
2
votes
1answer
582 views

Which would be a better way to load data via ajax

I am using google maps and returning html/lat/long from my MySQL database Currently A user picks a business category e.g; "Video Production". an ajax call is sent to a CodeIgniter controller the ...
1
vote
2answers
492 views

SQL language drawbacks, The Third Manifesto

Sometime ago I read about SQL language drawbacks (the basic language specification, not vendor specific), and one of the drawbacks was that the language does not allow to create a set of tuples that ...
5
votes
5answers
384 views

Alternatives for comparing data from different databases

I have two huge tables on separate databases. One of them has the information of all the SMS that passed through the company's servers while the other one has the information of the actual billing of ...
0
votes
2answers
324 views

Will TSQL become useless because of new ORMs? [closed]

By introducing LINQ to SQL, I found myself and my .NET developer colleagues gradually moving from TSQL to C# to create queries on the database. Entity Framework made that shift almost permanent. Now ...
2
votes
5answers
3k views

SQL Strings vs. Conditional SQL Statements

Is there an advantage to piecemealing sql strings together vs conditional sql statements in SQL Server itself? I have only about 10 months of SQL experience, so I could be speaking out of pure ...
1
vote
1answer
5k views

how to compare two large sets of data using PL/SQL?

I have two different tables in two separate databases with around 1.5 million records each. (BTW: im working on oracle databases) The objective is to check if every record present in table A is ...
3
votes
1answer
517 views

How would one build a relational database on a key-value store, a-la Berkeley DB's SQL interface?

I've been checking out Berkeley DB and was impressed to find that it supported a SQL interface that is "nearly identical" to SQLite. ...
1
vote
1answer
315 views

Implementing Bulk Update feature and its trade offs

The feature to implement is to allow a user to select items and apply data update in bulk. It is very similar to JIRA's ability to bulk update a list of selected issues. In my case: I iterate over ...
5
votes
2answers
345 views

Good architecture for user information on separate databases?

I need to write an API to connect to an existing SQL database. The API will be written in ASP.Net MVC3. The slight problem is that with existing users of the system, they may have a username on ...
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) ...
4
votes
3answers
335 views

Rule of thumb for field sizes

What VARCHAR sizes should be used for first and last names, phone numbers (preferably international), email adresses, urls, dictionary words and file names? Edit: Zapped the introductory phrase to ...
3
votes
4answers
190 views

What's the utility of encouraging users to learn SQL and possibly the ability to execute it?

Facing a situation where I can't possibly get all the features that are requested into each version of the LOB I support, I've evolved a number SQL query templates that users have and send to me, ...
4
votes
6answers
2k views

Confusion about proper use of * wildcard in SQL [duplicate]

Suppose I was writing an address book application where the details of each contact were stored in an SQL database. A user wants to know all the details for a person whose name is "Bob [Someone]". ...
26
votes
7answers
40k views

How do I make complex SQL queries easier to write?

I'm finding it very difficult to write complex SQL queries involving joins across many (at least 3-4) tables and involving several nested conditions. The queries I'm being asked to write are easily ...
1
vote
2answers
1k views

Designing complex query builders in java/jpa/hibernate

I need to build complex sql queries programatically, based on large filter conditions. For example, below are few sample/hypothitical filter conditions, based on which i need to fetch users Country: ...
2
votes
2answers
351 views

Where should SQL/DB Queries be encapsulated in a software system?

I frequently write small applications (either web based or otherwise) that require heavy database usage. i've attempted various ways of handling where to put the actual sql queries (sort of ad-hoc ORM ...
1
vote
2answers
662 views

SQL DB design to support user feeds (in application like facebook)

I have a social network server with a MySql DB. I want to show the users feeds like done in Facebook. Example - UserX now Friend with userY, userX did like on postX etc. Currently I have table: C1 : ...
9
votes
6answers
560 views

Software solution from the 2000's, should I attempt to patch or remake the whole thing?

I was sent out to discuss a system that a certain company is currently using and what should be done with it. The company manufactures various carton displays. This system was developed to keep track ...
3
votes
7answers
5k views

What is the best approach for database design with lots of columns?

I am writing a query based financial application. It lets the user to write complicated equations (much like WHERE part of an SQL query) and find companies matching those criteria. For the above, I ...
4
votes
4answers
2k views

Can NoSQL databases be used in e-commerce companies for order management?

Is it possible to use a non relational database be in an Order management system for an e-commerce company with a large number of orders everyday, like Amazon? Can the benefits of Non Relational ...
0
votes
4answers
212 views

Is it possible (or desirable, if not) to make an database engine organize the order of sql statements to maintain the referential integrity?

Today at work I found the following situation: We had two tables, A and B, with B having a foreign key linked to the primary key of A. On our application, we got two main situations that created ...
6
votes
5answers
2k views

What are the advantages to using SQL query builders?

Are there any advantages to using a query builder, rather than using raw SQL? E.g. $q->select('*') ->from('posts') ->innerJoin('terms', 'post_id') ->where(...) vs: SELECT * FROM ...
3
votes
7answers
215 views

Throwing an Exception if a Query Doesn't Use an Index

I'm working on a largish webapp that was developed by several other programmers and I keep running into performance issues caused by poorly written SQL queries and queries that don't use an index. ...
0
votes
1answer
165 views

Recommendation for a database to query records with attributes that are arrays or hashes?

I'm building site with a very simple data structure: documents that are nodes that reference other nodes that each have arrays of parents, children and siblings, so the structure is: Node: uuid name ...