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

-11
votes
0answers
24 views

SQL SERVER DATA BASE ADMINISTRATOR [on hold]

I WANT TO BECOME A DATA BASE ADMINISTRATOR. WHAT COURSE SHOULD I DO AND WHERE. THANKS
-2
votes
0answers
15 views

how to make an interactive databaseplatform [on hold]

Hi i have a bunch of information on excel spreadsheets, however i want to turn this into an interactive searchable platform online so my clients can easily navigate the infomation, what kind of ...
2
votes
1answer
605 views

How to translate SQL query into REST API requests?

Let's say I have a machine-readable description (such as in WADL, Swagger or RAML) of a REST API that provides interface to a database. My users submit queries about underlying database in form of ...
0
votes
1answer
72 views

Relational Database with XML [on hold]

I want to create a Metadata server in which I can store different Metadata from different file types. There are existing standard tags in Exif or IPTC-Core Metadata which I can input as columns in the ...
1
vote
1answer
51 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 ...
1
vote
1answer
174 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? ...
-2
votes
0answers
6 views

PHP/SQL Question [migrated]

There's my problem... I have the following variables: $days_a = $array_total['days']; // This one display days $hours_a = $array_total['hours']; // This one display hours $minutes_a = ...
3
votes
3answers
230 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
2answers
72 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 ...
10
votes
4answers
714 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. ...
2
votes
0answers
66 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 ...
2
votes
0answers
69 views

is there a way to tell JDBC I am about to execute a transaction? [migrated]

when setting AutoCommit to false; is this means that I have to commit after executing every sql command in my application. here is a scenario SQL1 doesn't need to be a transaction. SQL2 needs to ...
-3
votes
0answers
30 views

How to use a JOIN SQL statement in ASP.NET using Access? [migrated]

OK so I am a programming student with a headache that hopefully someone will be able to cure. I am currently creating a website using ASP.NET in Microsoft Visual Studio for a project and here is my ...
0
votes
1answer
32 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 ...
3
votes
4answers
310 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 ...
1
vote
2answers
663 views

Database Context and Singleton injection with IoC

All of the below relates to a ASP.NET c# app. I have a Singleton Settings MemoryCache that reads values from database on first access and caches these, then invalidates them using SQL Service Broker ...
2
votes
5answers
153 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
177 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 ...
0
votes
2answers
55 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 ...
-5
votes
1answer
60 views

How best to design a SQL Parser in java, any prevailing design pattern comes to mind? [closed]

What software pattern is most useful for building a SQL Parser? I would like some ideas on how to even get started on something like this.
2
votes
2answers
110 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 ...
1
vote
1answer
271 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 ...
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. ...
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 ...
10
votes
6answers
4k views

Code formatting SQL queries

Should I break SQL queries in different lines? For example in the project I am working on, we have a query that is taking 1600 columns! 1600 + tab chars. I wrote queries like this: "SELECT bla , ...
-1
votes
1answer
142 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 ...
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 ...
15
votes
7answers
713 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 ...
1
vote
1answer
33 views

Custom Domain or Attribute Reference Table or Both?

I'm designing my first real database and I'm weighing the pros and cons of how to enforce uniformity in my data. My first option is to create a custom domain and program my UI to only allow certain ...
1
vote
1answer
91 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
208 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, ...
15
votes
4answers
3k 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 ...
6
votes
7answers
358 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 ...
0
votes
0answers
43 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
172 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
263 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
2answers
104 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 ...
2
votes
3answers
133 views

Managing database schema for a C++ app

I have an open source project (Cockatrice) that uses mysql for the server component. I'm planning some changes to the schema, but right now the only management I have is a script that runs the proper ...
0
votes
0answers
45 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
2answers
112 views

Best way to store revision information for quick access to view or revert changes

What I am looking for is the most optimal solution for storing content revisions in an MSSQL database. We have an application that allows users to make changes to small HTML content blocks similar to ...
0
votes
1answer
163 views

MongoDB: Replicate data in documents vs. “join”

Disclaimer: This is a question derived from this one. What do you think about the following example of use case? I have a table containing orders. These orders has a lot of related information ...
3
votes
2answers
83 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 ...
0
votes
1answer
125 views

Refactoring a Single Rails Model with large methods & long join queries trying to do everything

I have a working Ruby on Rails Model that I suspect is inefficient, hard to maintain, and full of unnecessary SQL join queries. I want to optimize and refactor this Model (Quiz.rb) to comply with ...
0
votes
0answers
55 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 ...
13
votes
3answers
2k views

Best way to organize SQL queries stored in your code ? (or should you?) [closed]

I am sure I am not the only one who gets frustrated when they see a page of code littered with SQL queries. The ActiveRecord and other ORM patterns help mitigate a good amount of SQL used in a ...
4
votes
2answers
234 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 ...
-4
votes
1answer
90 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
57 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 ...
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 ...
-1
votes
3answers
190 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 ...