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
1k 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 ...
4
votes
7answers
211 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
156 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 ...
5
votes
7answers
299 views

Logistically, how do you manage embedded SQL?

My current application is running into issues with its ORM, and we're relying on some pretty hairy SQL to express queries that the ORM can't. Are there best practices in terms of how to manage the ...
2
votes
1answer
504 views

Sanity of design for my in-memory object representations of database rows

I've been trying to revise the structural design of the C#.NET-based system I'm currently working on. The new design involves a rather light-weight object-relational mapping framework (we're trying ...
8
votes
5answers
707 views

Why is SQL known as a relation-based / functional language?

We're learning that most languages are classified as either of the two, "relation based" or "high level". I've never used SQL before, but from reading its syntax it seems more like the ...
4
votes
2answers
518 views

Is a traditional client app which connects directly to a database a good idea?

After using Django's excellent admin interface, I was pondering creating a similar system which wasn't as tied to an ORM. Now, while considering this, I thought that overcoming webapps limitations ...
9
votes
3answers
2k views

Maintaining referential integrity between a mobile client and a server

So I have a relatively simple system. A mobile client creates records in a sqlite database that I would like to have synced to a remote SQL server (that is shared with other mobile clients). So when I ...
9
votes
4answers
4k views

Best way to maintain data between local and remote sql databases

So I have, what would seem like a common question that I can't seem to find an answer to. I'm trying to find what is the "best practice" for how to architect a database that maintains data locally, ...
0
votes
2answers
263 views

How to solve a fundamental cloud data storage dispute?

I'm working for a company that has recently hired me to create a new version of their existing software, which is now over 12 years old. The new software is a complete re-write of the old and they ...
5
votes
4answers
17k views

Best practice to query data from MS SQL Server in C Sharp?

What is the best way to query data from a MS SQL Server in C Sharp? I know that it is not good practice to have an SQL query in the code. Is the best way to create a stored procedure and call it ...
5
votes
2answers
2k views

How can I design a model layer without ORM, and when should I use it?

I'm a PHP developer who started with CodeIgniter. In it, designing models was easy: it seemed like each method defined in models was the equivalent of static methods in a normal, objected-oriented ...
3
votes
3answers
1k views

T-SQL stored procs orders of magnitude faster than LINQ

According to answers I've seen on stackoverflow, stored procedures (and to a lesser extent db functions) tend to perform better vs. LINQ + ORM frameworks (e.g. Entity Framework). I want to determine ...
0
votes
2answers
130 views

Suggestions for search methodology requested

I am throwing this question out to the 'greater creativity' for some suggestions on search methodology that might solve this problem. I have come up with a somewhat contrived example to attempt to ...
52
votes
6answers
3k views

Why the Select is before the From in a SQL Query? [closed]

This is something that bothered me a lot at school. 5 years ago, when I learned SQL, I always wondered why we specify first the fields we want and then where we want them from. According to my idea, ...
-1
votes
9answers
307 views

Can you share an explanation or experience that gave you clarity about how to use SQL SELECTS? [closed]

I have been programming for a long time, like 13 years (only professionally for about 4). I've become familiar with things like QBasic, Visual Basic, C#, .NET, Java, C, C++, Javascript, JQuery, etc. I ...
2
votes
1answer
3k views

Automatically adding data from JSON to SQL

I'm really new to this sort of stuff; my background is in C# mainly. Could anyone point me in the right direction? I need to set a script to automatically parse some JSON into an SQL database ...
0
votes
2answers
341 views

Programming certificates [duplicate]

Possible Duplicate: Are certifications worth it? I'd be glad to hear your opinions on which programming certificates are the most widely recongnized in the industry and how useful are they ...
3
votes
2answers
262 views

two approaches to database modeling - which one to use when

recently I have noticed a new approach to data modeling vs what I have used so far. This seems to be a way to address modeling of an entity that has a very large set of fields and quite often many of ...
1
vote
5answers
649 views

Worst practices in developing database applications [closed]

In constrast to http://programmers.stackexchange.com/questions/123591/database-design-good-practices I wanted to ask: What are the top worst practises you encountered when having to work with other ...
3
votes
2answers
892 views

Bill of materials database design in EF codefirst?

I'm having trouble generating a proper database design for bill of materials in EF Code-first I just need a general structure then ill add additional fields So i need to have a Product that is ...
5
votes
1answer
10k views

Entity Framework vs. Linq to SQL? [closed]

I'm a little bit confused about these two terms "Linq to SQL" and "Entity Framework". I have the general idea that both of them somehow allow you to refer to database tables as .net objects or ...
14
votes
6answers
23k views

SQL Triggers and when or when not to use them.

When I was originally learning about SQL I was always told, only use triggers if you really need to and opt to use stored procedures instead if possible. Now unfortunately at the time (a good few ...
13
votes
6answers
2k views

Interacting With Data Using Multiple Databases/Servers

All of the projects that I've had to deal with so far have only required a single database on a single server. I'm interested in learning more about how projects that need to scale move to multiple ...
0
votes
3answers
520 views

What is likely to be the bottleneck between the SQL Server, IIS and .net when receiving json as text from the DB?

I have spent the best part of a month working on the jQuery Calendar plugin. The setup is such that all the calendar entries are stored in a table inside SQL Server and im using a single "Select As" ...
6
votes
2answers
366 views

What are some useful resources for learning tuple calculus?

I've been trying to go over my tuple calculus over and over again. What's worse is that my professor and tutors are not much help during their hours. Does anyone know a good place to learn about ...
2
votes
2answers
183 views

Are there standard strategies for defining job flow and dependencies?

I'm working on a project that involves the chaining of separate jobs into a single master job, though there may be parallel paths in the chain leading up to the final output. Job and chain details ...
119
votes
19answers
25k views

Why is naming a table's Primary Key column “Id” considered bad practice? [closed]

My t-sql teacher told us that naming our PK column "Id" is considered bad practice without any further explanations. Why is naming a table PK column "Id" is considered bad practice?
7
votes
2answers
2k views

Algorithm for formating SQL code

I need a tool (for in house usage) that will format SQL code (SQL Server/MySQL). There are various 3rd party tools and online web sites that do it but no exactly how I need it. So I want to write my ...
4
votes
2answers
172 views

When and how much should we validate input when working with (C)AP storage?

Herein, we consider a server-client architecture. Suppose we keep the details flexible, but there's more than one layer of servers supporting our hypothetical service. The general question is "When ...
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 ...
4
votes
2answers
148 views

What is the equivalent of functions and methods in SQL?

In language like C or Java, there are things like functions/methods to modularize and abstract stuff. What is there in SQL, specifically for Oracle? I've seen people talking about using views to ...
5
votes
2answers
178 views

Storing stop/start points in a database

Let's say I am storing start and stop points per user into a database table. For example... let's say in a chat system, a user only needs to see lines 24-293, and 500-512. (Let's say he logged off ...
2
votes
3answers
1k views

How to reach to the advanced level in SQL? [closed]

I think I have a good grasp of SQL and the most features it has, but sometimes when I've done some more advanced Reporting Services a fellow developer has helped me with some stuff and when I open ...
3
votes
3answers
752 views

Why put SQL statement in a variable before using mysql_query()?

I'm been working with PHP on and off for a bit now, and I've seen plenty of code both ways: $sql = "SELECT …"; mysql_query($sql); vs mysql_query("SELECT…"); Is there a reason for separating the ...
53
votes
6answers
3k views

Is this a ridiculous way to structure a DB schema, or am I completely missing something?

I have done a fair bit of work with relational databases, and think I understand the basic concepts of good schema design pretty well. I recently was tasked with taking over a project where the DB was ...
2
votes
5answers
215 views

For user defined data, is it better to use a table of tables or dynamically created tables?

In an application that allows users to define their own tables and columns (details of that are not the focus of this question, but imagine a tool that lets users create their own forms and ...
4
votes
8answers
896 views

Are Bools/Bits Faster Than Integers

As the title suggests I'm wondering whether bools or bits are faster than using integers (1 and 0)? Specifically I thinking about their speed in CASE statements, even more specifically in T-SQL ...
6
votes
4answers
474 views

What are the options when Sql generated by ORM needs tuning?

I am starting working on a web project using django. While researching whether to use Sqlalchemy or raw sql when django orm is not sufficient which is also a question I asked here Raw Sql vs ...
6
votes
1answer
2k views

Raw Sql vs SqlAlchemy when Django ORM is not enough

In a django project, if a situation comes that Django ORM is not able to execute some complex queries then there are 2 options: Use Raw Sql queries Use SqlAlchemy I want to know if there are ...
15
votes
7answers
653 views

To Domain or not to Domain

The SQL92 and SQL99 standards define CREATE DOMAIN DDL constructs. Not all databases support this, or have a different name for it (SQL Server has User Defined Types, for example). These allow one to ...
16
votes
2answers
1k views

Does F# offer anything particularly useful for database-driven web development?

My organization finally upgraded to MS Visual Studio 2010 this year. One of the big new features that Visual Studio 2010 offers is the F# programming language. I understand that F# offers a ...
3
votes
5answers
2k views

Best practices for generating new identifiers for persistent objects?

In a typical scenario, an object that needs to be persisted in the database will be created in application code without an identifier, and later saved to a table in the database. Some database ...
4
votes
2answers
4k views

Why NoSQL over SQL? [duplicate]

Possible Duplicate: When would someone use MongoDB (or similar) over traditional RDMS? How well the SQL and NoSQL go head-to-head. I read somewhere that SQL databases are not well for data ...
3
votes
4answers
722 views

Other things to learn for becoming a Database Admin/Developer?

Obviously i'll have to make some sort of choice at what DB i choose to go with (MS-SQL/MYSQL/etc) but this question isn't about that. The question mainly is what other languages/tools would be ...
2
votes
4answers
420 views

Job market-wise, are more and more companies moving to NoSQL? [closed]

I know NoSQL isn't nearly as mature, but it's been about a year or so since I've kept up with anything recent. Is it still "the future", are companies moving towards this, or are they still stuck in ...
0
votes
5answers
3k views

Developing a simple web-application?

I decided to do a mini-project by myself to help me understand a bit more about developing web applications before starting the new university semester. Using the Java SE and JEE/J2EE platforms. I ...
0
votes
3answers
109 views

Trying to evaluate answers provided by an online technology school

I've been considering taking some web-related programming courses from an online technology school (it's probably best if I don't name names). When I read the syllabi of the different courses on their ...
5
votes
3answers
2k views

Managing SQL Stored Procedures' Version

I am working with a team of 5 persons. We are using SQL Server as our database. Since long time I want to store the Stored Procedures in SVN so that the versions can be maintained. Is there any tool ...
4
votes
4answers
715 views

Multiple Joins or Simple Readable Database Calls

Curious how other developers feel about this. I come across some pretty nasty sql joins, as we all do I'm sure. I would prefer making more database calls for the sake of readability and simplicity ...