SQL Server BasicsWhat is SQL Server database?What is RDBMS?What is Normalization?Why we use Denormalization?What_is_SQL?What is PL/SQL?Difference between SQL and PL/SQLDatabase TableOne to One RelationshipOne to Many RelationshipMany to Many RelationshipMany to One RelationshipString Data TypesNumber Data TypesDate Data TypesOther Data TypesCreate DatabaseDrop DatabaseCreating and Managing Users in SQL ServerCreate TableAlter TableDrop TableConstraints in SQL serverPrimary KeyForeign KeyUnique KeyCandidate KeyComposite KeyDifference between primary key and candidate keyPrimary key and foreign key relationshipSurrogate KeyCascading Referential Integrity ConstraintsSelf Referential Integrity ConstraintsInsert into statementInsert multiple recordsUpdate statementDelete statementTruncate statementDifference between Delete and TruncateAlias in SQL ServerSelect statementSelect DistinctSelect TopSelect IntoNull Functions(ISNULL(),NULLIF(),COALESCE())Sub QueryIdentity ColumnSequence objectDifference between sequence and identity columnSQL Server ClausesWHERE ClauseOrder By ClauseTop N ClauseGroup By ClauseHaving ClauseDifference between Where and HavingSQL Server OperatorsArithmetic OperatorsComparison OperatorsLogical OperatorsBitwise OperatorsAny OperatorsAll OperatorsUnion OperatorsUnion All OperatorsDifference between Union and Union AllIntersect OperatorExcept OperatorDifference between Except and IntersectJoinsInner JoinLeft JoinRight JoinFull JoinSelf JoinCross JoinViewsWhat are views?Create views using SSMSIndexed ViewsComplex ViewsCheck Option in ViewCheck Encryption in ViewSchema Binding Option in ViewRead-only ViewsUpdatable ViewsAdvantages and disadvantages of viewsCreate multiple views on one tableCan we implement index on views?Can we Perform Insert, update, delete operation on views?Stored Procedure and FunctionsWhat are Stored Procedures?Why we use stored procedures?Passing parameters to Stored procedureUser-Defined FunctionsDifference between UDF and Stored procedurePre-Defined Functions@@Indentity and Scope_IndentityNULLIF, ISNULL and COALESCE

Can we create multiple views on one table?

Yes, it is possible to create multiple views on a single table in a database. Each view can have its own unique definition and present the data from the underlying table in a different way. Creating multiple views on a table allows for various perspectives or subsets of the data to be easily accessible without modifying the underlying table structure.

Let's consider an example where you have a table called Employees with columns such as EmployeeID, FirstName, LastName, Department, and Salary. You can create multiple views on this table to provide different perspectives or subsets of data based on specific criteria or requirements. Here's an example of creating multiple views on the Employees table:

1-All Employees:


CREATE VIEW vw_AllEmployees
AS
SELECT * FROM Employees;

This view simply selects all columns from the Employees table, providing a view of all employees.

2-Employees in the Sales Department:


CREATE VIEW vw_SalesEmployees
AS
SELECT EmployeeID, FirstName, LastName, Salary
FROM Employees
WHERE Department = 'Sales';

This view selects specific columns from the Employees table but filters the data to only include employees in the Sales department.

3-High-Salary Employees:

    
CREATE VIEW vw_HighSalaryEmployees
AS
SELECT EmployeeID, FirstName, LastName, Salary
FROM Employees
WHERE Salary > 50000;

This view selects specific columns from the Employees table but filters the data to only include employees with a salary higher than 50,000.

You can create as many views as needed based on the requirements of your application or reporting needs. Each view provides a different perspective on the same underlying table data, allowing you to query and analyze the data from various angles without modifying the original table structure.

Once these views are created, you can query them just like you would query a table. For example, to retrieve all employees in the Sales department, you can simply execute:


SELECT * FROM vw_SalesEmployees;

Views provide a way to simplify data access, provide data security by controlling column visibility, and allow for logical organization of data based on specific criteria or requirements.

Each view can have its own unique SQL query that defines the data and presentation. It's important to note that while views can present data in different ways, they don't create separate copies of the data. Instead, they provide a virtual representation derived from the underlying table.

Creating multiple views on a table can be beneficial when different users or applications require access to the same underlying data but with different perspectives or customized presentations.