Structured Query Language is a language for interacting with relational databases. Read the tag wiki's guidelines for requesting SQL reviews: 1) Provide context, 2) Include the schema, 3) If asking about performance, include indexes and the output of EXPLAIN SELECT.
-3
votes
1answer
56 views
2
votes
1answer
15 views
Stored procedure to swap account holders
I'm doing an exercise, and would like to know if what I'm doing is correct and follows the correct structure for rollback in case a transaction fails. I would like to know as well if my ...
-4
votes
0answers
12 views
login of two tables with one procedure in asp.net [on hold]
I have 2 tables one is passengers and second is driver but am confuse how to make one login page for both users, i can not write stored procedure of login for both tables.
...
3
votes
2answers
64 views
Checking a user's emails using an ID
I'm trying to do this:
Getting user's ID based on his email name.
Using that user_id to check all his emails that have been sent for him so far.
...
3
votes
1answer
38 views
Grabbing SQL records: Nullable bool to bool
So I have a method that does a lookup in an existing List<T>, populated elsewhere by grabbing the records from a SQL table holding configuration data for each ...
0
votes
0answers
9 views
1
vote
0answers
23 views
Export database values as csv with a helper class
Should I be using getter and setter functions in my class nodeStruct?
I am currently using them where there is need to manipulate the input value (e.g for ...
3
votes
1answer
28 views
Database design for users' postcards
I would like to a review of my database design.
There are 3 tables + ASP.NET Identity tables.
The Users could have many postcards.
Here's my tables without Identity.
I attached also my scripts ...
-2
votes
0answers
12 views
Issue with SQL script [closed]
I hoping somebody can help with a sql issue I have. WE have sales orders and works orders. I am looking at the works order history table called bmhstm. In this table we have works orders that have ...
1
vote
0answers
18 views
Database schema for factory application
I am creating an application to manage the assembly of shoes through a web application.
Could you tell me that you think that is more or you would be missing to be as solid and complete as possible, ...
2
votes
1answer
61 views
Simple login page
Could anyone tell me if this code is well written and if it has bugs / vulnerabilities?
class.user.php:
...
0
votes
1answer
31 views
Repair orders query in SQL Server with subselects
I was wondering if you guys know how to reduce the amount of subselects in this SQL Server Query? I think I'm using bad practices in this:
...
0
votes
0answers
11 views
Spark Code for doing SQL Operations on a/ multiple JSON files
Input is one or many json files to run a query and print the result.
I have tried both Collect and saveAsTextFile but both are slow and would appreciate suggestions to help speed things up.
Here is ...
0
votes
1answer
40 views
6
votes
4answers
653 views
SharePoint CRUD class
I am writing an application where I have some objects like customer, supplier, product, etc.
I have written a class for the object 'supplier' and wanted to ask if this is a good design. I have put in ...
2
votes
1answer
46 views
Checking whether a store is open or not by querying over its business hours
I currently have a method that checks if the store is open. It's working nicely, however on the main page I have quite a few stores. Whom again have different locations. Each of these locations again ...
-3
votes
0answers
30 views
4
votes
0answers
55 views
Stored procedure to insert a new person
I have not written very many stored procedures before, and this is the first one I have written to be used in a real business application to write new data into the database, so I would like to get ...
4
votes
2answers
90 views
Social network queries for profiles, posts, and followers
The code below is for a social networking system. The problem is that when there are many posts and many followers, the performance is slow. Is something wrong with the queries and the script below?
...
7
votes
0answers
33 views
Flexible Chutes & Ladders using SQL stored procedure
I thought this would be a fun exercise to use SQL to participate in the June 2016 Community Challenge, so I did. Yes, you may call me crazy!
I had to write a few little things to help me, I needed a ...
1
vote
0answers
27 views
Returning direct status changes of user statuses
I have a query which returns direct status changes (no intermediary changes) of user statuses:
...
3
votes
2answers
43 views
Finding maxDate for each entity
I have a table with (CompanyNumber, File_Date, [various financial results])
I wanted to get only the most recent set of accounts for each company.
After various ...
1
vote
0answers
11 views
1
vote
2answers
83 views
Properly structuring SQLite classes/operations in Android
I am new to Android development and I want to ensure I'm learning decent practices for doing things. Right now this is my database class, which currently allows me to make a new instance of the ...
4
votes
1answer
81 views
Sanitizing words extracted from text files and writing them to a database
This code reads text files from some path, tokenizes, removes stop words, lowercases, removes punctuation and numbers, then writes the result to a database.
...
-1
votes
1answer
53 views
Getting unique Ids by bulk via sql sequence object [closed]
Following code provides unique Ids for adding new rows in a SQL database from a SQL sequence object (e.g. ...
1
vote
5answers
71 views
A like/unlike system using MySQL and PDO
I have created a Like/Unlike system. The user clicks one to indicate a "like", and clicks again to "unlike" it. Currently I do that like this:
...
1
vote
0answers
26 views
Business Access Layer and Data Access Layer for a database application
Would like to get your opinion and any advice regarding my current approach of creating database applications. Below find my current approach. Counting on your opinion and comments including examples ...
4
votes
2answers
66 views
Fetching the website version number from the database
I was just writing some code the other day, and I found myself writing something I am not sure whether it is OK to do it like this, or not.
Let me give an example of what this is:
I have this Method:...
2
votes
0answers
20 views
GUI rogram connecting to SQL and listing information about products in specific category
This is my very first application written in Java and so I finalized it, solely because it occurred to be my thesis.
It is a very simple program that lists categories (Northwind database is used as ...
1
vote
1answer
24 views
Get all members from country depending on multiple tables
I have 4 tables, filled with some example data
user table
...
0
votes
0answers
29 views
MySQL stored procedure to search medical insurance claims
This stored procedure is taking a lot of time to execute. How can I optimize this query?
...
2
votes
2answers
65 views
SQL Query over ODBC is slow with DISTINCT
Is there any way to simplify this query? It's being run against a Progress Database via an ODBC connection.
The CustomerSalesperson table has a ...
4
votes
2answers
46 views
Adding dynamic column names to a table
I'm using Microsoft SQL Server 2014 Express.
I found myself wanting to add the Columns CompanyNameChangeDate (1 through 10) and ...
6
votes
2answers
56 views
Database design for a transportation company
I am designing a database and I am just wondering if I am doing it correctly. I have tables for things like State with all the states in them and then I reference the ID in other tables. But should I ...
2
votes
1answer
47 views
Sales report for an invoicing system
I am creating a sort of Sales Report for an Invoicing System.
I have an extremely complex MySQL Query that takes a very long time to execute (usually about 10 - 15 seconds). It involves multiple ...
1
vote
0answers
21 views
Get percentage on the fly with AND and LIKE
Aim: Get percentage based on if field is blank or not
Issue: Unknown amount of variables based on search and thus speed
Solution: Dynamic SQL build up
Looking for: Tips to speed up even more/spot ...
4
votes
3answers
53 views
Data import “upsert” from a SSIS package
I have the following "upsert" trigger in SQL Server 2005, which is handling a large data import from a SSIS package. It is taking a very long time to complete - I suspect due to the concatenation and ...
1
vote
2answers
62 views
Reading CSV files and inserting in a SQL database in VB.Net
This program reads all files in a folder and subfolders line by line, converts them in a supported character set, replaces all unsupported characters and inserts them in a SQL database. My idea was to ...
1
vote
1answer
46 views
Reducing the time of Update and Sum Query C# Access DB?
I have a simple query using query builder of VS2012 C# which updates the database in my winforms application. The database has 216 entries so far and it's taking a lifetime to update the database. How ...
7
votes
2answers
1k views
Wrapper for commonly used database classes
The main idea behind this class is to create a wrapper for commonly used Database classes. I'm new to SOLID principles and I'm trying to implement them in this library. Does this code adhere to SOLID ...
3
votes
0answers
14 views
Data Explorer query that makes bar graphs
I wrote a query for SEDE that I think is pretty cool. It uses the currently available graphing capabilities (scatter plots) to create a bar graph. I have used it as the subject for a self-answer on ...
1
vote
1answer
43 views
Demographics information for EDI report
I am going through some of my companies EDI reports to see if I can make them faster. The query below runs in less than one second in our AWS RDS environment, but it takes ~55 seconds on a blade in ...
1
vote
0answers
39 views
SQL query with nested subqueries
The following query is taking over 800ms to run, and returning 300 rows.
...
0
votes
1answer
33 views
SQL query with GROUP BY to show badges and points by user and course
I have the following database schema. My goal is to obtain a result set that lists the total badge points earned by each user. The badges might be earned in different courses. I want to include the ...
4
votes
1answer
59 views
SQL query that flattens many-to-one relationships
I have a database with these tables, where each mapping table represents a "many-to-one" relationship between the table on the right and the table on the left (click to enlarge):
I am selecting a ...
1
vote
2answers
86 views
Select random row using PDO
What do you think of this way to generate a random number from the total rows in a table? I would like to create a page that random.php precisely generates a random ID and shows it.
...
1
vote
1answer
48 views
Get time slots based on multiple workshops
I have a list of Workshops, each having open days (Monday, Tuesday etc.) and open time and close time (which will be same for each day). Now, Based on the current time, I need to find out next 7 days ...
2
votes
1answer
34 views
Query column names and then using them in statements
I currently have a table with over 250 columns, in which ~10-15 columns have column names that have a specific prefix, namely EQP_.
Assume that you do not want to ...
0
votes
1answer
33 views
Get properties from all children in a recursive SQL structure
In our product, Company is a model that can have many Companies belonging to it; so some Companies are parents, some are children, and many are both.
We have a ...