Search This Blog

Q46-Q50

Q46.  What are the difference between Count(*) and Count(column name) in sql?
Q47. What is CQRS? when to use it?
Q48. What is composite primary key?
Q49. Difference between Dirty reads and Phantom Reads?
Q50. What are different types of isolation level in sql?

==================================================================================
Q46.  What are the difference between Count(*) and Count(column name) in sql?

Answer:
Performance wise there is not much difference that much care about. but in count we might get different value if our column name have nulls in some rows. 

Count(*)- return you count of all rows present. means it will have calculated even is 5 columns out of 6 columns are null. 

Count(columnname) - Give you count only for non null values of that column. 
==================================================================================
Q47. What is CQRS? when to use it?

Answer:
It is one of the database pattern and can be used in microservices and distributed systems. 

CQRS - Command Query Responsibility Segregation. 
CRS +QRS = CQRS

Command - Perform an action like create, update, delete in database. 
Query - Perform an action of retrieving the data. ie View of data

Here we maintain two database 1 for Command actitivites like creation update, delete of records and 
2nd for view of database. 

Data Replication techniques between two database
1) Event handlers: when there is a change in DB1 it will publish an event witch will be captured by DB2
2) SQL Triggers and procedures: Plain old technique by which we can copy data from one place to another. 

==================================================================================
Q48. What is composite primary key?

Answer:
When a composite key act as a primary key. it is called composite primary key. 

==================================================================================
Q49. Difference between Dirty reads and Phantom Reads?

Answer:


==================================================================================
Q50. What are different types of isolation level in sql?

Answer:


==================================================================================