What is SQL (4 points)
Write a Create Table statement in SQL Server?
What is RDBMS and its characteristics?
RDBMS is referred to as Relation Database Management Systems (RDBMS). RDBMS possesses the following characteristics:
What is the database engine in SQL Server?
What is PL/SQL?
SQL
PL/SQL:
What is ADO.net
What is a Check in SQL?
A Check Constraint is a rule that identifies valid values for columns of data. A Check Constraint helps to enforce Domain Integrity. If the condition in a Check Constraint is not satisfied, it prevents the value from entering the database.
Create table tableName(Column1 dataType Check(expression), Column2, columnN)
create table emp(empId int check(empId >10),empName varchar(15))
What is a default in SQL?
The default constraint allows you to set a default value for the column.
When a row is created for the first time, and there is no entry specified for the column that has a default constraint on it, then the default value is stored in the column.
The default value for the column is set only when the row is created for the first time,,e and the column value is ignored on the Insert.
Note that this is not a Not Null constraint.
Modifying the column with a NULL value or even the Insert operation specifying the Null value for the column is allowed.
What is a constraint in SQL
Constraints are the rules that decide what kind of data can enter into the database tables. SQL server has six types of constraints, and we will explore all these constraints here with suitable examples. The constraints that we are going to explore are listed below:
What is a Primary Key Constraint and it syntax?
CREATE TABLE Persons (
ID int NOT NULL PRIMARY KEY,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Age int
);multiple columns
CREATE TABLE Persons (
ID int NOT NULL,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Age int,
CONSTRAINT PK_Person PRIMARY KEY (ID,LastName)
);What is a Not Null Constraint?
This constraint is useful to stop storing the null entries in the specified columns.
CREATE TABLE table_Name ( column1 data_type(size) NOT NULL, column2 data_type(size) NOT NULL, …. );
How do I define constraints in SQL?
Create Table My_Constraint ( IID int NOT NULL, Salary int CHECK(Salary > 5000) )
What is a database table?
Create table TableName (columnName1 datatype, columnName2 datatype )
How do you create a table in SQL?
Create table TableName (columnName1 datatype, columnName2 datatype )
OR
create table Info ( Name varchar(20), BirthDate date, Phone nvarchar(12), City varchar(20) )
How to delete a table in SQL Server?
Delete TableName
How to update a SQL Server database table using SQL?
ax Update TableName SET ColumnName = NewData where Condition Update info Set City = 'Baroda' where id = 2
What are the relationships in the SQL Server database?
One-to-Many & Many-to-One Relationship
For a One-to-Many relationship, a single column value in one table has one or more dependent column values in another table. Look at the following diagram:
Many to Many Relationship
The third table acts as a bridge between the tables that want to establish a Many-to-Many relationship. The bridge table stores the shared information between Many-to-Many relationship tables. Have a look at the following diagram:
What is the primary key of a database?
A table column with this constraint is called the key column for the table. This constraint helps the table to make sure that the value is not repeated and also that there are no null entries.
Now, this column does not allow null values and duplicate values. You can try inserting values to violate these conditions and see what happens. A table can have only one Primary key. Multiple columns can participate in the primary key.
What is a foreign key of a database?
To define the relationship between two tables (one is called the parent and the other one is the child table) connected by columns, a foreign key constraint is used. In this constraint, the values of the child table must appear in the parent table, which means that for a foreign key, one table should point to a Primary Key in another table. A table can have multiple foreign keys,s and each foreign key can have a different referenced table.
CREATE TABLE table_name ( Col1 datatype NOT NULL, Col2 datatype NOT NULL, Col3 datatype NOT NULL, CONSTRAINT FK_Column FOREIGN KEY(Col1, Col2, Col3) REFERENCES parent_table(Col1, Col2, Col3) );
Continue here at normalization https://www.c-sharpcorner.com/UploadFile/puranindia/sql-server-interview-questions/
What is ACID?