Relational Flat File ---- ---- ---- ---- ----- ---- …… … . Producer Album Artist CD No Artist Album Producer
Relational Design Basics contd…. Entity – Relationship Model ER model is a conceptual data model that views the real world as entities and relationships. Entities - Entities are the principal data object about which information is to be collected. e.g . Employee, Department etc. Attributes - Attributes describe the entity of which they are associated. A particular instance of an attribute is a value . e.g . Employee can have attributes like Employee Name, Employee Number etc. Relationships – Relationship represents an association between two or more entities.
Bob 135 Name Customer ID 32 135 Age Customer ID 1 1 1 136 1/1/07 222 Bob 135 Name Customer ID ABC Shipping 1 Name Shipper ID 1 1 Shipper ID 136 135 Customer ID 1/1/07 111 1/1/07 222 Date Order No 1 Many 1 Many Bob 135 Name Customer ID ABC Shipping 1 Name Shipper ID 1 Shipper ID 135 Customer ID 1/1/07 111 Date Order No 1 Many 1 Many 1 1/1/07 222 ABC Shipping 1 Name Shipper ID 1 1/1/07 111 Date Shipper ID Order No 1 Many
In Outer Join besides returning matching rows from both tables, the rows from the preserved table that have no match in the other table are also returned, padded with NULLs instead of the values that were supposed to come from the other table.
SELECT * FROM Employees AS E RIGHT OUTER JOIN Departments AS D ON E.deptno = D.deptno
NULL 20 10 JobID Engineering 300 NULL NULL NULL Deptname Deptno Salary Empname Empid Management 200 2000 Bob 2 Production 100 1000 Leo 1
JOIN Keyword - FULL Outer Join SELECT * FROM Employees AS E FULL OUTER JOIN Departments AS D ON E.deptno = D.deptno NULL 30 20 10 JobID Engineering 300 NULL NULL NULL NULL NULL 1500 Jeffrey 3 Deptname Deptno Salary Empname Empid Management 200 2000 Bob 2 Production 100 1000 Leo 1
It cannot store data. It can only refer to data present in tables.
CREATE VIEW <view name>
[optional] WITH SCHEMABIND
[optional] WITH ENCRYPTION
Creating a view with the SCHEMABINDING option locks the tables being referred by the view and prevents any changes that may change the table schema.
If a view is created with ENCRYPTION option, Users will not be able to see the definition of the View after it is created. The view definition will be stored in an encrypted format in the system table named ‘syscomments’
Views can be used to insert, update and delete data.