Posts

Showing posts from September, 2022

Normalization in SQL

Image
 Normalization :-        Normalization is a Database technique which can help us to remove redundancy. Redundancy         means In a colum1 Country and  column2 Sales so here we are adding the sales of Country.                             In country Column i have India and Ind Both meaning are same but when i find total record of        India it will give me 700 Sales so this is redundancy .For removing redundancy we need to create a       master table and where we can add Country and  link it with relationship.                            1st Normalization ,2nd Normalization, 3rd Normalization :-       Multivalued :- same Column Can have comma separate Files or more than 1 values.              ...

STORE PROCEDURE AND FUNCTION

Image
 STORE PROCEDURE :-   Store Procedure is a reusability of code it can be invoke by using Exec.  so if i have any sql query that  i write over  and over again then i will save it to store procedure and just call it to execute it  HOW TO CREATE STORE PROCEDURE: first select your database then click on Programmability and in  Programmability we have Store Procedure.  so for creating a new Store Procedure just right click on Store procedure and select New Store Procedure SO here patientEFcore  is my database and inside it i have Programmability and in  Programmability i have Store Procedure. so in PatientEFcore i have tables here in tblPatient i am creating Store Procedure for Patientid .  soo this is my  new Store Procedure  CREATE PROCEDURE Sp_getpatientId       //Sp_getpatientId i named my store Procedure @Id int                          ...

MSSQL DataTYPE

Image
  💓 Mssql Datatype can have int ,char ,varchar ,decimal ,bit ,money    1)  Integer :Integer can store whole value like Id, Age  can take 4byte of data to store.                                tinyInt :- 1byte ,smallInt: 2byte ,mediumInt : 3 byte,Int :4byte,bigInt :5byte    2)  Char : Char is a Fixed Length .char can store English character and  Number. Store 1byte of data    3)  Varchar : Varchar  is a variable Length it store English char and number.    4)  Decimal :Decimal can store the exact value in database.  decimal(P,D)                    P = Precision , D = Digit     5) Bit : Bit can store the value 0 and 1 0 = false ,1 = true.     6)Money : Money can store the Currencly Value          Also we have nChar and nVarchar ...
 SQL PERFORMANCE TUINING :-    1) CLUSTER AND NON-CLUSTER INDEX :-       both can be used for searching purpose.        CLUSTER INDEX :          It can be used for searching purpose          Any column can have  Primary key or index then it will be a cluster index.        there will be only 1 cluster index in a table.      eg:-       select * from Appoinmnet where id=51;         1)soo cluster index 1st create B-tree n divide index value 1-50 and 51-100   (balance tree it can balancely divide the records agar 100 he to  50 ,  50  me divide krega)             2)then  index can check condition is 50<51 not so skip 1-50 and search on 51-100 index        3) it gate 51 index then it index have leaf node which provide him value   ...