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.
0
votes
1answer
23 views
Large MySQL Batch Inserts From PHP: Run insert from script, or save as SQL file?
We have a large dataset that's current residing in many, many spreadsheets.
I've been tasked with getting part of that data into our MySQL DB.
When all is said and done, I will probably be inserting ...
0
votes
1answer
33 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 ...
-1
votes
0answers
26 views
What's a good example of why I would use Doctrine Native SQL? [on hold]
I use Doctrine ORM for everything database related. I've never used Doctrine Native SQL and was looking for a reason why I would use it. I know and understand what it does but I can't think of any ...
0
votes
0answers
61 views
Explaining Cursor Loop in SQL [on hold]
I need to explain what is a Cursor Loop in simple terms. My Customer is not a technical person but he wanted to understand it. I explained to him on a Stored Procedure he showed me that this part is ...
-4
votes
1answer
56 views
PHP - mysql like operator not work [on hold]
I tried to execute this code, but my web browser give a error
mysql_fetch_assoc() expects
$sql = "SELECT * FROM word WHERE ENGLISH LIKE '$notFind%'";
$result = mysql_query($sql, $conn) ...
-1
votes
0answers
19 views
UnixODBC driver issues for .MDF databases. OR: is there a way to easily extract a bunch of tables without an sql server? [on hold]
Disclaimer: I am somewhat of a n00b when it comes to database programming, so bear with me.
I've been attempting to batch process a rather large amount (~20 gb) of data all contained in .MDF SQL ...
2
votes
1answer
61 views
Implementing Syncing between localStorage and SQL database?
I have made a simple web app, which runs completely offline - all data is saved in HTML5's localStorage. Now, I want the data to get synced with the server, so that the user is able to use the app on ...
2
votes
0answers
167 views
Is database version control practical? [closed]
The topic of database version control seems to come up at my work and in social discussion more and more often. But the truth is, I haven't met anyone actually DOING it.
The only thing Googling the ...
0
votes
0answers
31 views
Charts, SQL and REST?
We have created a REST API for a voting game. Now we are jumping into creating analytics/graphs/charts for moderators and users to watch how are they doing in the game.
The game has a certain group ...
0
votes
2answers
106 views
When do you use subquery in SQL? [closed]
When do you use subquery in SQL, and what type of request is subquery useful for? I am practicing SQL and need to know how to spot a subquery problem immediately
0
votes
0answers
36 views
SQL Permissions differ in SSMS and ASP.NET? [migrated]
I have created a schema and user called "WebAPI" which is used by ASP.NET project to get stock levels.
So, I have simple stored procedure:
SELECT p.ProductCode,
SUM( sl.Qty ) AS 'Qty'
FROM ...
2
votes
6answers
240 views
Using a relational database vs JSON objects for event/activity data
I am working on a project where I am trying to decide between using a standard SQL relational database or JSON objects to store data about an event or activity.
The project will store data on ...
0
votes
2answers
63 views
Return multiple columns with SQL where GroupBy is on one column [closed]
I have noticed that all the columns in a SQL Select Query should be in a aggregate function, because otherwise the output value for group would be arbitrary.
This makes sense. But when the other ...
2
votes
1answer
171 views
Is there a purely SQL alternate to looping?
Historically, I probably would have written a script (php or something) to loop through all spreadsheet rows and perform some calculations.
I'm looking for a pure SQL solution on the presumption ...
0
votes
3answers
62 views
Maintaining indices for location in a sorted list in database rows
I have a fairly simple data structure like this:
create table project (id int auto increment primary key, name text);
create table item (id int auto increment primary key, name text,
project_id ...
79
votes
10answers
10k views
Why is “Select * from table” considered bad practice
Yesterday I was discussing with a "hobby" programmer (I myself am a professional programmer). We came across some of his work, and he said he always queries all columns in his database (even on/in ...
0
votes
4answers
213 views
How to handle or prevent all Admins and users being removed
I have a website that stores all users in a database. A user can log on to the website and if they have sufficient privileges can add/delete users, as well as change their privileges.
How do I ensure ...
0
votes
1answer
94 views
Why doesn't MySQL have an explicit “No Limit” option for queries?
I use SQLyog Community edition and like many other SQL applications out there it puts a 1000 result limit on queries that do not have a limit provided.
I am wondering why MySQL doesn't have an ...
-2
votes
2answers
150 views
Should an expert in SQL have the same skills as a DBA? [closed]
A new employee in my company recently jioned as a DBA. He's on a different team than me. I told him my boss is "pretty-much a DBA", this because I know he's expert in SQL.
But I think i slightly ...
-3
votes
1answer
62 views
Is there any site like http://asp.net to learn sql basics and advanced concepts online [closed]
I am looking for online SQL Tutorial sites that will teach me about advanced SQL as well as the basics.
I have already come through w3schools.com and sqlzoo.net, but I was looking for a site that is ...
3
votes
5answers
159 views
Is it bad software design to mix JDBC SQL calls and use an ORM in an application? [closed]
Is it bad software design to have JDBC/raw SQL and also use an ORM? I don't mind using an ORM for boilerplate CRUD, but some queries are better in SQL (for me). I'm not arguing for or against ORMs. ...
6
votes
2answers
269 views
Slight extension for SQL prepared statements syntax. Need advice
In my database abstraction library I am extending SQL prepared statements syntax to hint a parser with expected literal type. I take it as a very essential improvement, my reasoning you can read here. ...
4
votes
2answers
331 views
How deeply programmer should know about internals of database engine? [closed]
I am learning SQL Server 2012 along with C#. In the past, I took database class in college, and have good grasp on SQL language and can write queries. However, looking at SQL Server documentation (or ...
2
votes
1answer
173 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
3answers
84 views
SQL string field lengths in a db having about 6 different types of addresses, with about 20 markets and environments
I have been advocating lately that all string fields should be ntext / nvarchar(max) - we're using MS SQL Server. The objections seem to be either "it's not a good idea" (without any reason) or "that ...
0
votes
1answer
154 views
What happens if computer crashes after giving commit command
If we are updating a field in SQL and ALTER the row also. After giving the COMMIT command, the system is crashed.
What will happen to the commands given, whether it will UPDATE and ALTER the table ...
1
vote
3answers
66 views
Select custom output formats from database with SQL
I am planning to make a simple rest service application, and I am currently deciding the architecture. I have decided that I want to write the middle layer in multiple languages, so that it is easy to ...
0
votes
0answers
25 views
Using a single table for identity and metadata
I'm in the early design phase of a project to provide an e-commerce platform that will require several entities to be modelled, products, customers, orders, CMS pages, etc. They will all have a few ...
1
vote
1answer
339 views
Do software developers write SQL? [closed]
Do software developers write SQL or database developers provide the SQL and the software developers use it? I am a novice to software development. I am just trying to understand the software ...
2
votes
2answers
119 views
Use Of Exists clause in SQL
Just finished Stanford lecture on SQL (by Prof. Jennifer Widom). However I have developed a confusion regarding the use of EXISTS clause. I thought it is just like a condition and an expression so ...
0
votes
0answers
60 views
what should I save in local android DB to be more efficient and to last more than one session (and shouldn't be stored in the server only)?
I write an android app.
The user sends the server its location and get places relevant to him.
He then can up-vote or down-vote any offer.
I wonder if I should write to local DB and when?
I ...
0
votes
0answers
21 views
database design for Media company in SQL 2008
I have to make the report for one of the client. There are three sources from I will get all raw data, so eventually I will have to marry those all data from different sources and make one report. ...
3
votes
3answers
375 views
Is it better to use a switch statement or database to look through 5,000 to 10,000 instances?
I have some JSON data in this format (5,000 instances for now):
{"id":"123456","icon":"icon.png","caseName":"name of case"}
I am allowing the user to search for the name of the case and then return ...
4
votes
4answers
310 views
Choosing value in SQL query vs (Java) code
I need to choose one of three values of an integer using the value of a column on a nullable column of a table.
There are at least two approaches: 1) use SQL to do all the work: test null values, and ...
0
votes
3answers
124 views
High-Level SQL Interoperability
In a server -> client scenario, wouldn't it be simpler and faster to grant a public user access to a Stored Procedure rather than using web services (XML, REST, SOAP, etc) and other interoperable ...
0
votes
1answer
74 views
How to combine Google Analytics with Relational Database
I have a website with quite a lot of registered users, they are stored in a PostgreSQL database. I also running Google Analytics on the website to track the users. Is there a way to individually ...
1
vote
1answer
293 views
Creating a online database creator
I've been thinking of creating an online database creator (think DabbleDB, Zoho Creator, Intuit Quickbase, etc.).
I've been thinking of a couple solutions:
Have 4 database tables: Tables, Rows, ...
0
votes
4answers
124 views
When to store Date/DateTime?
I'm working on a social network website and I'm not quite sure when I should store the date/datetime. The service includes some of the following events:
Register/Login
Follow
"Like" (images & ...
2
votes
1answer
100 views
Mental schema for SQL queries
While preparing SQL introductory material, I've ended asking myself about the line of thought followed by a developer when writing a query. I believe it could be too valuable from a beginner's point ...
-2
votes
1answer
83 views
Finding next free IP in a network
I have an IP network and want to automatically find a free IP address to provision a new server. Due to frequent server additions/removals the used IPs might be quite fragmented over the whole address ...
2
votes
0answers
130 views
Match buyers and sellers based on date ranges and quantity of shares
NOTE: This is in reference to the question I asked on Stack Overflow but was told to post this here
I'm building a trading application that matches buyers/sellers that own subscription. Subscriptions ...
3
votes
5answers
239 views
Violating SQL principles
I have to write a decent size database, 1GB more or less.
I have only taken an introductory semester regarding SQL databases. During the course we learned that the relational model under SQL has no ...
0
votes
2answers
456 views
Lead developer unable to do INNER JOIN [closed]
I had worked in the past for a small company developing web applications. Back then the current lead developer, who is also one of the bosses, told me that he is incapable of making a JOIN inside a ...
0
votes
1answer
304 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 ...
1
vote
0answers
118 views
What database structure is suitable for tracking File audits?
I need to track permissions and access requests to a file server in a database. I'm given the full path of the folder and am considering parsing the path (splitting on the "/" character) and creating ...
2
votes
2answers
103 views
SQL Query syntax - formatting?
I'm looking at a very large (5-6 digit LOC), very complex, code-base, full of interacting bulky, interdependent, views and stored procedures (multiple 4-5 digit count silos).
The source SQL has been ...
4
votes
3answers
211 views
How to avoid unmaintainable code when using SQL in an MVC setting?
I want to present a list of products to the user. This list is paginated and can be sorted by the user by product ID or product name in ascending or descending order.
I am using an MVC setting, where ...
0
votes
1answer
153 views
How exactly can I check for new rows in sql with ajax? [closed]
How do certain services, just like google plus and facebook, check for new content without reloading the page? Whenever you are on any of those websites a new notification of a post related content ...
0
votes
1answer
91 views
How to store Status for Reservation table
I have a reservation table (a user fills out a form to request a reservation).
It has two parts that need to be confirmed. isReservationAccepted (decline,accept,waiting) and hasReservationBeenSent ...
0
votes
1answer
108 views
Queries in three tier architecture
I am wondering where should the DB queries need to be in the three tier architecture.
The first association that think is in the DAL. But then if the BL want to search for an object, the DAL need to ...