Skip to main content
46 votes

Does `COUNT` discard duplicates?

Either your professor made a mistake or you misunderstood what she said. In the context of relational DBMSes, as implemented by various vendors, the aggregate function COUNT(<expression>) ...
mustaccio's user avatar
  • 26.2k
39 votes
Accepted

Does `COUNT` discard duplicates?

COUNT does count duplicates in all DBMS I'm aware of, but. Is there any reason for a professor to teach this behaviour Yes, there is a reason. In the original relational theory (that underlies all ...
Vadim Pushtaev's user avatar
14 votes

Does `COUNT` discard duplicates?

If your professor is talking about SQL, the statement is wrong. COUNT(x) will return the number of rows where x IS NOT NULL including duplicates. COUNT(*) or COUNT([constant]) is a special case that ...
Lennart - Slava Ukraini's user avatar
9 votes
Accepted

Will Postgres handle the Unix Epoch problem?

If you look at https://www.postgresql.org/docs/11/functions-datetime.html in the documentation it displays data about the to_timestamp function that returns a timestamp with time zone value from an ...
Patrick Mevzek's user avatar
9 votes
Accepted

Does a primary key contain exactly one Null value...?

No attribute that is part of a key can contain nulls; if a column is nullable then it isn't part of any key. It is also the case that the set of columns defined by a UNIQUE or PRIMARY KEY constraint ...
nvogel's user avatar
  • 3,777
7 votes
Accepted

Does the term "page" have the same meaning in DBMS and OS jargons?

Does the term page have the same meaning in DBMS and in OS? Generically, yes. The term PAGE is a generic for the smallest allocate-able unit of space. In SQL Server, for example, pages are a fixed ...
Sean Gallardy's user avatar
6 votes
Accepted

need sql to represent relation negation and date compare problem

The problem is not simple as it involves 2 entities/tables (Employee and Project) that have 2 relationships between them. One is through the Department (a project belongs to a department, an employee ...
ypercubeᵀᴹ's user avatar
6 votes

Can independent applications cause roll back to each other's transactions?

I want to understand if there is a possibility that transaction being run via one application can affect the ones from an independent other application. Directly, no. Each transaction is by ...
LowlyDBA - John M's user avatar
5 votes

Can a/some DBMS be installed as an OS

Yes. IBM i, formerly known as AS/400, is a platform with the operating system that has a relational DBMS as its integral part. Indeed, Db2 for i is in a way an alternative access method to the IBM i ...
mustaccio's user avatar
  • 26.2k
4 votes

Why are there so many definitions of database?

If you compare any two authorative references for a single subject they will employ different words even though they convey the same meaning. This is just the nature of English - it has a very rich ...
Michael Green's user avatar
4 votes

Does `COUNT` discard duplicates?

This is how it works in MS SQL Server COUNT(*) returns the number of items in a group. This includes NULL values and duplicates. COUNT(ALL expression) evaluates expression for each row in a ...
Daniel Björk's user avatar
4 votes
Accepted

Why is a port needed for DBMS?

A port number is not necessary to use DBMS. Individual programs could write directly to the DBMS's files. But the rules of a DBMS have become very complex, and an immense amount of logic is needed to ...
Gerard H. Pille's user avatar
4 votes
Accepted

Nosql vs sql for genre management

The only real questions to mainly be considered when choosing between NoSQL and a Relational Database Management System (RDBMS) are: "Does the data have a well defined structure or is it very ...
J.D.'s user avatar
  • 38.1k
3 votes

Can a/some DBMS be installed as an OS

Googling a bit I found another operating system called TabulaROSA. Designed by MIT it works on 32k core supercomputers, if you or your company can afford a system like that, it could be a good ...
McNets's user avatar
  • 23.8k
3 votes

Can independent applications cause roll back to each other's transactions?

If your code does not affect Isolation Level of your queries, non of your apps can make queries to Rollback. They can only Suspend each other. Use a SQL Server Profiler to track your app and see ...
El.Hum's user avatar
  • 182
3 votes
Accepted

problem with selecting correct values from database

1) select TOP (1) ename,salary from Employee where classification='4' order by salary desc 2) select did,dname from Department where exists (select 1 from Employee group by did,...
S4V1N's user avatar
  • 1,064
3 votes

Most suitable database design for multi store inventory?

This is not a challenge for one, modern RDBMS. You will realize you do not want to have one database per store the first time executive management asks for "How many iPhone 7s do we have on hand ...
CalZ's user avatar
  • 924
3 votes
Accepted

is "create schema" the same way of saying "create database"?

This is for SQLServer, databases and schemas are different in other DBMS like Oracle. A database and a schema are two different concepts. A database can contain multiple schemas, for example the ...
Yannick Liekens's user avatar
3 votes

Why is a port needed for DBMS?

In the SQL Server world, we have what was traditionally called "Network Library", which handles the communication between the client and the database server (nowadays this is often just ...
Tibor Karaszi's user avatar
2 votes

Grouping operator in DBMS (γ) is duplicate-impervious. Why?

In the book, "Garcia-Molina H., Ullman J., Widom J., Database Systems: The Complete Book. Pearson Prentice Hall, 2009", Chapter 5, "Algebraic and Logic Query Languages", on top of page 217 of the 2nd ...
Renzo's user avatar
  • 4,080
2 votes

CHECK constraint not implemented in MySQL, what about other DBMS?

Every R (relational) DBMS I've used has. MySQL is peculiar in so many ways I struggle to put it head to head with any of the "normal" RDBMS for anything other than a basic data dump for a simple ...
LoztInSpace's user avatar
2 votes

Does `COUNT` discard duplicates?

If the table had looked like this, | product | |id | length | code | |-------------------| | 1 | 11 | X00 | | 2 | 11 | C02 | | 3 | null | A31 | you could expect the query to ...
Terje's user avatar
  • 121
2 votes
Accepted

Running two MySQL servers that use the same data directory

Since the documentation tells you exactly what precautions to take, I was expecting this to actually work...or else, what's the point of that guide in the official documentation? If this couldn't be ...
RolandoMySQLDBA's user avatar
2 votes
Accepted

How do graph databases differ from older navigational (hierarchical/network) databases?

Graph databases are largely irrelevant. What matters is the graph processing engines that use them. For that a dedicated graph database is not necessary: graphs can be represented in any sorts of ...
Albert Godfrind's user avatar
2 votes

Will Postgres handle the Unix Epoch problem?

Don't worry about it, because they have added the beyond the year 2038 support more than ten years ago (!) in 8.4 release (2009): https://www.postgresql.org/docs/8.4/release-8-4.html
Acuna's user avatar
  • 129
2 votes

How many concurrent sessions does Oracle database support?

The number of concurrent sessions is determined by the values of PROCESSES and SESSIONS initialization parameters, provided that your hardware can handle that many of them. You can check the limits ...
mustaccio's user avatar
  • 26.2k
2 votes
Accepted

Physical co-clustering of two or more logical relations/tables in modern RDBMS

Is co-clustering still a valid option for optimization? Sure, it is a valid option for optimization, if your DBMS offers it. As David Browne has mentioned in a comment, only Oracle does (which, in a ...
mustaccio's user avatar
  • 26.2k
2 votes

Why is a port needed for DBMS?

A port is what allows any program to communicate over a network. Think of it like a television channel or radio frequency. Protocols like TCP and UDP are how programs communicate from port to port. ...
pmdba's user avatar
  • 3,114
2 votes

no matching unique or primary key for this column-list

you have a combined Primanry key. So use Create table Branch( Bid int primary key, Loc varchar(20), Sid int, Sname varchar(20), foreign key(Sid,Sname) references spare(Sid,Sname) ); Or you define in ...
nbk's user avatar
  • 8,434

Only top scored, non community-wiki answers of a minimum length are eligible