Upload
suzan-cobb
View
215
Download
2
Embed Size (px)
Citation preview
REZA HESHAMI
DBA Developer
Responsibilities Designing Relational databases Developing interface layer
Environment Microsoft SQL Server, .NETSQL Layer: Stored procedures, functions ,CLR
ObjectsObject Layer: ADO. Net , Microsoft enterprise
library, Object-Relational mappers Query optimization/Performance tuning
Code review for performanceMissing indices
Applications
Single Sign on (SSO) Search Solutions
Search DatabaseSearch Engines
Import/Export solutionsSending to and receiving data from web servicesXML/CSV transformation
Frameworks Data warehouse and OLAP
Challenges
PerformanceMissing indexPoorly written queries Normalized vs. DenormalizedDeadlocks
Design Schema flexible to changesDDL (data definition language) Vs DML(data
manipulation language)○ example
Simple example Design a database to store user information
Username ,password, first name, last name, postal code
Requirement changes Email, Address, City, Province, Country, language and etc now is needed to be stored . Solution ?
CREATE TABLE Users( UserID INT NOT NULL Primary Key, UserName NVARCHAR(50) NOT NULL, FirstName NVARCHAR(50) NULL, LastName NVARCHAR(50) NULL, PostalCode NVARCHAR(50) NULL);
Simple example Option 1 add more column to the Users table Option 2 insert rows instead of columns
(How)
CREATE TABLE Users( UserID INT NOT NULL Primary Key, UserName NVARCHAR(50) NOT NULL );CREATE TABLE Properties( PropertyID INT NOT NULL Primary Key, PropertyName NVARCHAR(50) NOT NULL )CREATE TABLE UserProperty( PropertyID INT NOT NULL Primary Key, UserID INT NOT NULL , value NVARCHAR(100) NOT NULL )
Many to Many Relation
XML DataType –Hybrid design
CREATE TABLE Users( UserID INT NOT NULL Primary Key, UserName NVARCHAR(50) NOT NULL , UserProperty XML);CREATE TABLE Properties( PropertyID INT NOT NULL Primary Key, PropertyName NVARCHAR(50) NOT NULL )CREATE TABLE UserProperty( PropertyID INT NOT NULL Primary Key, UserID INT NOT NULL , value NVARCHAR(100) NOT NULL )
XML DataType –Hybrid design XML Advantages
FlexibilityEasy to parse and to serialized in to objects
DisadvantagesSearching trough XML is SlowMaintenance – adds over head to insert and
update XML model is not a replacement for
Relational model
Good to know about
Paging in SQL Trees & Hierarchies in SQL Graph in SQL Recursive query in SQL (using Common
Table Expressions) XML manipulation (XPATH,XQUERY) CLR objects in MS SQL Server