Database design for a particular sales order scenario?

Please refer to the database design below: Consider a scenario where a sales order is created based on the prodcu...

Mapping Class Diagram into database table design?

I've taken the following class diagram and mapped it into a table design with appropriate keys etc... Am i thinking ...

GROUP BY combined with ORDER BY?

The GROUP BY clause groups the rows, but it does not necessarily sort the results in any particular order. To cha...

Adventure Works Explanation?

I've been looking at Microsoft's Adventure Works 2012 database. I'd be very interested if there's any information ex...

Analysis of SQL Schema: what is the purpose of loop in ProductCategory of AdventureWorks??

I want to understand the purpose of the loop in the ProductCategory table. AdventureWorks is a sample database here ...

How do I drop table variables in SQL-Server? Should I even do this??

I have a table variable in a script (not a stored procedure). Two questions: How do I drop the table variable? D...

Facebook database design??

I have always wondered how Facebook designed the friend <-> user relation. I figure the user table is somethi...

Entity Relationship Diagram for Hotel?

I need to create an ERD for a hotel, the question reads as follows: "The owner of a set of hotels would like to hav...

How do I do multiple CASE WHEN conditions using SQL Server 2008??

What I'm trying to do is use more than one CASE WHEN condition for the same column. Here is my code for the query: ...

Getting student name from student table belonging to a section with less than 5 students enrolled?

Hello there, I have a questions for you guys. You see enrollment and student table in images below. I want to run...

SELECT using Correlated Sub Queries and multiple tables?

I have two tables (Table1 & Table2). One including a date (tDate) column and an ID (tTillNo) column that I would...

Truncate multiple tables in one MySQL statement?

Is there a possibility to truncate with one SQL statement, multiple tables? Like this: truncate table #OBJ_Availa...

Select DISTINCT and MAX in the same query?

I have a table with rows/data in the following structure ----------- | SURVEY_ID | ------------ | 1 | | 2 ...

SQL keys, MUL vs PRI vs UNI?

What is the difference between MUL, PRI and UNI in MySQL? I'm working on a MySQL query, using the command: desc my...

How to find duplicate records in PostgreSQL?

I have a PostgreSQL database table called "user_links" which currently allows the following duplicate fields: year,...