Sunteți pe pagina 1din 31

1

Cuprins
1. Descrierea temei de proiect ...................................................................................................................... 2
2. Notiuni introductive .................................................................................................................................. 3
2.1. Despre baze de date .......................................................................................................................... 3
2.2. Tipuri de date n SQL .......................................................................................................................... 5
2.3. Interogri ........................................................................................................................................... 5
2.2. Despre Microsoft SQL Server 2012 Enterprise .................................................................................. 7
2.3. Crearea unei baze de date in SQL Server 2012 ................................................................................ 10
3. Diagrama ERD ......................................................................................................................................... 13
4. Modelul relational al bazei de date ........................................................................................................ 14
5. Cod SQL pentru creearea tabelelor, inserarea datelor .......................................................................... 14
6. Descrierea view-urilor. Codul sql pentru crearea lor .............................................................................. 19
7. Concluzii .................................................................................................................................................. 30
8. Bibliografie .............................................................................................................................................. 31














2











1. Descrierea temei de proiect

In acest proiect am realizat o baza de date pentru o platforma online tinand cont de
cererea pietei online si de amploarea cu care acest mediu se dezvolta. Aceasta baza
de date are rolul de a facilita informatii administratorului siteu-lui despre angajati,
clienti cat si gestionarea utilizatorilor site-ului in functie de rolul pe care acestia il
au. Aplicatia va imbunatatii interactiunea dintre utilizator si cel ce administreaza si
se ocupa de acesta platforma.Aceasta baza de date are toate atuurile unui sistem de
gestionare al utilizatorilor bine pus la punct.







3











2. Notiuni introductive

2.1. Despre baze de date

BD reprezint o colecie de date utilizat ntr-o organizaie, colecie care este
automatizat, partajat, definit riguros (formalizat) i controlat la nivel central.
[2]
SGBD reprezinta un ansamblu de programe ce permit utilizatorilor s
interacioneze cu o baz de date, n vederea crerii, actualizrii i interogrii
acesteia.[2]
Avantajele BD:
Un grad redus de redundan a datelor.
Diminuarea inconsistenei datelor.
Facilitarea partajrii informaiilor
4

Suport pentru standardizare.
Structurile de date sunt mai aproape de realitate i mai uor de manipulat.
Este permis legtura cu diverse limbaje-gazd.
Abordare global a ntreprinderii
Datele sunt separate de programele, iar procesul de dezvoltare a aplicaiilor-
program este sensibil ameliorat,
Sistemele informatice ce utilizeaz baze de date sunt mai flexibile, reflect mai
bine specificul firmei, fiind adaptabile la modificrile ulterioare ale mediului
economic [1]
Modelul de date relaional a fost propus de cercettorul E.F. Codd de la compania
IBM, care a publicat n anul 1970 lucrarea "Un model Relaional de Date pentru
Bnci Mari de Date Partajate" [Codd70]. Alte lucrri ale lui Codd, ca i ale altor
cercettori (C.J. Date, P. Chen, R. Boyce, J.D. Ullman, R. Fagin, W.W. Armstrong,
M. Stonebraker, etc.) au perfecionat modelul de date relaional i au permis
dezvoltarea fr precedent a sistemelor de gestiune a bazelor de date, datorit
simplitii i a fundamentrii matematice a modelului. [1]
SQL (Structured Query Language - Limbaj Structurat de Interogare) este un limbaj
de programare specific pentru manipularea datelor n sistemele de manipulare a
bazelor de date relaionale (RDBMS), iar la origine este un limbaj bazat pe algebra
relaional. Acesta are ca scop inserarea datelor, interogaii, actualizare i tergere,
modificarea i crearea schemelor, precum i controlul accesului la date. A devenit
un standard n domeniu (standardizat ANSI-ISO), fiind cel mai popular limbaj
utilizat pentru creearea, modificarea, regsirea i manipularea datelor de ctre
SGBD-urile (Sistemele de Gestiune a Bazelor de Date) relaionale. Pe lng
versiunile standardizate ale limbajului, exist o mulime de dialecte i variante,
unele proprietare, fiind specifice anumitor SGBD-uri i de asemenea coninnd
extensii pentru a suporta SBD-urile (Sistemele de Baze de Date) obiectuale
(obiectual-relaionale).[7]


5

2.2. Tipuri de date n SQL

Oricrei coloane (sau cmp) dintr-un tabel SQL i este asignat un tip de dat, la fel
ca n toate celelalte limbaje de programare. Tipurile de date sunt urmtoarele:
CHARACTER (sau CHAR) - ir de caractere
INTEGER (sau SMALLINT) - numr ntreg
FLOAT, REAL sau DOUBLE PRECISION - numr real
NUMERIC(precision, scale) sau DECIMAL(precision, scale) - numr zecimal ,
unde precision nseamn numrul de cifre din partea ntreag, scale nseamn
numrul de zecimale.
DATE - data zilei.
TIME - ora. Funcia sistem NOW ntoarce data i ora curent.[7]
2.3. Interogri

Cea mai des utilizat instruciune n SQL este instruciunea SELECT. [7]
SELECT [ALL | DISTINCT] coloana1 [,coloana2]
[INTO fiier]
FROM tabel1 [,tabel2]
[WHERE condiie] [ AND|OR condiie...]
[GROUP BY list-coloane]
[HAVING condiii]
[ORDER BY list-coloane [ASC | DESC] ]

6

Clauza INTO este utilizat pentru a transfera rezultatul interogrii ntr-o
nou tabel; valabil n Microsoft Access, dar nu n toate platformele SQL.
[7]
Clauza WHERE este utilizat pentru a specifica condiii trebuie s
ndeplineasc coloanele din care se face selecia. Aceast condiie este o
expresie logic obinut prin alicarea operatorilor conjuncie (AND) i
disjuncie (OR) asupra unor expresii logice elementare obinute cu
ajutorul operatorilor: = (egal), <> (diferit), < (mai mic dect), <= (mai mic
sau egal dect), > (mai mare dect), >= (mai mare sau egal dect), LIKE
(permite selectarea potrivirilor pariale cu ajutorul operatorului %; de
exemplu: select city, state from towntable where state LIKE 'north%'); [7]
Clauza GROUP BY permite gruparea coloanelor multiple n scopul
prelucrrii acestora prin funciile agregate:
o AVG - media aritmetic;
o COUNT - numrul articolelor;
o MAX - maximul;
o MIN - minimul;
o SUM - suma. [7]

Exemplu: Maximul populaiei tuturor oraelor americane din statul Indiana:
SELECT MAX(population) FROM citylist WHERE state = 'Indiana'; [7]
Clauza HAVING Spre deosebire de clauza WHERE, acioneaz asupra
rndurilor rezultate din clauza GROUP BY , aplicndu-le condiia, spre a
fi ulterior prelucrare prin funciile agregate. [7]
Clauza ORDER BY Ordoneaz rezultatele interogrii n ordine alfabetic
dup unul sau mai multe cmpuri. ASC nseamn n ordine cresctoare,
iar DESC - ordine descresctoare. Ordinea implicit este cresctoare. [7]
Alte cuvinte cheie:
ALL - Toate articolele;
DISTINCT - Numai articolele unice, fr duplicate. [7]
7


Exemple:
Selectarea tuturor crilor din tabela Book, avnd preul mai mare dect
100.00, n ordinea cresctoare a titlurilor:

SELECT * FROM Book WHERE price>100.00 ORDER BY title;

Selectarea tuturor titlurilor crilor din tabelele Book i a autorilor crilor
citii din tabela Authors:

SELECT Book.title, Authors.name FROM Book INNER JOIN Authors ON
Book.author = Authors.id GROUP BY Book.title;
2.2. Despre Microsoft SQL Server 2012 Enterprise

O Baz de date, uneori numit i Banc de date, reprezint o modalitate de stocare
a unor informaii i date pe un suport extern (un dispozitiv de stocare), cu
posibilitatea extinderii uoare i a regsirii rapide a acestora. La prima vedere
sarcina poate prea banal. Totui, n condiiile n care este vorba de a lucra cu
milioane de elemente, fiecare putnd consta din mari cantiti de date care trebuie
accesate simultan prin Internet de ctre mii de utilizatori rspndii pe ntreg
globul; i n condiiile cnd disponibilitatea aplicaiei i datelor trebuie s fie
permanent (de ex. pentru a nu pierde ocazia de a ncheia afaceri), soluiile bune nu
sunt de loc simple.[5]
De obicei o baz de date este memorat ntr-unul sau mai multe fiiere. Bazele de
date sunt manipulate cu ajutorul sistemelor de gestiune a bazelor de date.Cel mai
rspndit tip de baze de date este cel relaional, n care datele sunt memorate n
tabele. Pe lnga tabele, o baz de date relaional mai poate conine: indeci,
proceduri stocate, declanatori, utilizatori i grupuri de utilizatori, tipuri de date,
mecanisme de securitate i de gestiune a tranzaciilor etc.Alte tipuri de baze de
8

date sunt modelul ierarhic, modelul orientat pe obiecte i, mai nou, modelul
XML.[5]
Microsoft SQL Server este un sistem de gestionare de baze de date relaionale
(RDBMS) produs de compania american Microsoft Corp. Limbajul principal de
interogare este T-SQL.[6]

Suport versiunea companiei Microsoft de SQL (Structured Query Language -
limbaj structurat de interogri), cel mai rspndit limbaj pentru bazele de date. Este
un sistem pentru ntreprinderi - se poate aplica bazelor de date de dimensiuni foarte
mari.[6]
Microsoft SQL Sever foloseste o varianta de SQL numita T-SQL, sau Transact-
SQL, o implementare de SQL-92 (standardul ISO pentru SQL) cu unele extensii.
T-SQL in principal adauga sintaxa aditionala pentru procedurile stocate si pentru
tranzactii. Standardele SQL necesita ACID; acesta este un acronim pentru cele 4
conditii pentru orice tranzactie: atomicitate, consistenta, izolare, durabilitate. MS
SQL Server suporta ODBC (Open Database Connectivity).[6]

Urmatoarea poza reprezinta cum a scazut vulnerabilitatea diferitelor baze de date
comparativ cu sql server 2012+:

9




Cteva limitri generale :
Dimensiunea maxim a bazei de date: 524 PB
Dimensiunea maxim a unei nregistrri: cat suporta calculatorul utilizatorului
Memoria maxima utilizata: cat suporta calculatorul utilizatorului
Nr maxim de core-uri folosite de o instanta: cat suporta calculatorul utilizatorului
Dimensiunea maxim a unui cmp: cat suporta calculatorul utilizatorului
Numr maxim de nregistri ntr-o tabel: nelimitat
Numr maxim de coloane ntr-o tabel: nelimitat[4]

Urmatoarea poza reprezinta informatii despre Microsoft SQL Server 2012:
10


2.3. Crearea unei baze de date in SQL Server 2012
Pasul 1.Click dreapta de database si click pe new database:
11


Pasul 2. Se completeaza database name si owner

Se apasa ok, apoi se da click dreapta pe table si add new table:
12













13

3. Diagrama ERD


Tabela aspnet_Membershit este legata de tabela aspnet _Users prin cheia primara
ApplicationId.
Tabela aspnet_Users este legata de tabela aspnet_Applications prin cheia primara
ApplicationId.
Tabela aspnet_Users este legata de tabela aspnet_Profile prin cheia primara ApplicationId.
Tabela aspnet_Users este legata de tabela aspnet_PersonalizationPerUser prin cheia straina
compusa UserId.
Tabela aspnet _Paths este legata de tabela spnet_PersonalizationAllUsers prin cheia straina
PathId.
Tabela aspnet_UsersInRoles este legata de tabela aspnet_Roles prin cheia straina RoleId.

14

4. Modelul relational al bazei de date
Descriere relatiilor dintre tabele si asocierile dintre acestea realizate cu
ajutorul foreign key:
Un utilizator trebuie sa aiba un singur Membership.
O aplicatie trebuie sa aiba unul sau mai multi utilizatori.
Un utilizator trebuie sa aiba una sau mai multe roluri pe server.
Un utilizator este posibil sa aiba un singur profil.
Un utilizator trebuie sa aiba unul sau mai multe personalizari.
O aplicatie trebuie sa aiba unul sau mai multe cai.
O cale trebuie sa aiba una sau mai multe personalizari.
O personalizare generala trebuie sa aiba o singura cale.
5. Cod SQL pentru creearea tabelelor, inserarea datelor

USE [AspNetMembership]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[aspnet_Applications](
[ApplicationName] [nvarchar](256) NOT NULL,
[LoweredApplicationName] [nvarchar](256) NOT NULL,
[ApplicationId] [uniqueidentifier] NOT NULL,
[Description] [nvarchar](256) NULL,
PRIMARY KEY NONCLUSTERED
(
[ApplicationId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
UNIQUE NONCLUSTERED
(
[ApplicationName] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
UNIQUE NONCLUSTERED
(
[LoweredApplicationName] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
15

CREATE TABLE [dbo].[aspnet_Membership](
[ApplicationId] [uniqueidentifier] NOT NULL,
[UserId] [uniqueidentifier] NOT NULL,
[Password] [nvarchar](128) NOT NULL,
[PasswordFormat] [int] NOT NULL,
[PasswordSalt] [nvarchar](128) NOT NULL,
[MobilePIN] [nvarchar](16) NULL,
[Email] [nvarchar](256) NULL,
[LoweredEmail] [nvarchar](256) NULL,
[PasswordQuestion] [nvarchar](256) NULL,
[PasswordAnswer] [nvarchar](128) NULL,
[IsApproved] [bit] NOT NULL,
[IsLockedOut] [bit] NOT NULL,
[CreateDate] [datetime] NOT NULL,
[LastLoginDate] [datetime] NOT NULL,
[LastPasswordChangedDate] [datetime] NOT NULL,
[LastLockoutDate] [datetime] NOT NULL,
[FailedPasswordAttemptCount] [int] NOT NULL,
[FailedPasswordAttemptWindowStart] [datetime] NOT NULL,
[FailedPasswordAnswerAttemptCount] [int] NOT NULL,
[FailedPasswordAnswerAttemptWindowStart] [datetime] NOT NULL,
[Comment] [ntext] NULL,
PRIMARY KEY NONCLUSTERED
(
[UserId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[aspnet_Paths](
[ApplicationId] [uniqueidentifier] NOT NULL,
[PathId] [uniqueidentifier] NOT NULL,
[Path] [nvarchar](256) NOT NULL,
[LoweredPath] [nvarchar](256) NOT NULL,
PRIMARY KEY NONCLUSTERED
(
[PathId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[aspnet_PersonalizationAllUsers](
[PathId] [uniqueidentifier] NOT NULL,
[PageSettings] [image] NOT NULL,
[LastUpdatedDate] [datetime] NOT NULL,
PRIMARY KEY CLUSTERED
(
[PathId] ASC
16

)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[aspnet_PersonalizationPerUser](
[Id] [uniqueidentifier] NOT NULL,
[PathId] [uniqueidentifier] NULL,
[UserId] [uniqueidentifier] NULL,
[PageSettings] [image] NOT NULL,
[LastUpdatedDate] [datetime] NOT NULL,
PRIMARY KEY NONCLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[aspnet_Profile](
[UserId] [uniqueidentifier] NOT NULL,
[PropertyNames] [ntext] NOT NULL,
[PropertyValuesString] [ntext] NOT NULL,
[PropertyValuesBinary] [image] NOT NULL,
[LastUpdatedDate] [datetime] NOT NULL,
PRIMARY KEY CLUSTERED
(
[UserId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[aspnet_Roles](
[ApplicationId] [uniqueidentifier] NOT NULL,
[RoleId] [uniqueidentifier] NOT NULL,
[RoleName] [nvarchar](256) NOT NULL,
[LoweredRoleName] [nvarchar](256) NOT NULL,
[Description] [nvarchar](256) NULL,
PRIMARY KEY NONCLUSTERED
(
[RoleId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

17

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[aspnet_SchemaVersions](
[Feature] [nvarchar](128) NOT NULL,
[CompatibleSchemaVersion] [nvarchar](128) NOT NULL,
[IsCurrentVersion] [bit] NOT NULL,
PRIMARY KEY CLUSTERED
(
[Feature] ASC,
[CompatibleSchemaVersion] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[aspnet_Users](
[ApplicationId] [uniqueidentifier] NOT NULL,
[UserId] [uniqueidentifier] NOT NULL,
[UserName] [nvarchar](256) NOT NULL,
[LoweredUserName] [nvarchar](256) NOT NULL,
[MobileAlias] [nvarchar](16) NULL,
[IsAnonymous] [bit] NOT NULL,
[LastActivityDate] [datetime] NOT NULL,
PRIMARY KEY NONCLUSTERED
(
[UserId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[aspnet_UsersInRoles](
[UserId] [uniqueidentifier] NOT NULL,
[RoleId] [uniqueidentifier] NOT NULL,
PRIMARY KEY CLUSTERED
(
[UserId] ASC,
[RoleId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
ALTER TABLE [dbo].[aspnet_Applications] ADD DEFAULT (newid()) FOR [ApplicationId]
GO
ALTER TABLE [dbo].[aspnet_Membership] ADD DEFAULT ((0)) FOR [PasswordFormat]
GO
18

ALTER TABLE [dbo].[aspnet_Paths] ADD DEFAULT (newid()) FOR [PathId]
GO
ALTER TABLE [dbo].[aspnet_PersonalizationPerUser] ADD DEFAULT (newid()) FOR [Id]
GO
ALTER TABLE [dbo].[aspnet_Roles] ADD DEFAULT (newid()) FOR [RoleId]
GO
ALTER TABLE [dbo].[aspnet_Users] ADD DEFAULT (newid()) FOR [UserId]
GO
ALTER TABLE [dbo].[aspnet_Users] ADD DEFAULT (NULL) FOR [MobileAlias]
GO
ALTER TABLE [dbo].[aspnet_Users] ADD DEFAULT ((0)) FOR [IsAnonymous]
GO
ALTER TABLE [dbo].[aspnet_Membership] WITH CHECK ADD FOREIGN KEY([ApplicationId])
REFERENCES [dbo].[aspnet_Applications] ([ApplicationId])
GO
ALTER TABLE [dbo].[aspnet_Membership] WITH CHECK ADD FOREIGN KEY([UserId])
REFERENCES [dbo].[aspnet_Users] ([UserId])
GO
ALTER TABLE [dbo].[aspnet_Paths] WITH CHECK ADD FOREIGN KEY([ApplicationId])
REFERENCES [dbo].[aspnet_Applications] ([ApplicationId])
GO
ALTER TABLE [dbo].[aspnet_PersonalizationAllUsers] WITH CHECK ADD FOREIGN KEY([PathId])
REFERENCES [dbo].[aspnet_Paths] ([PathId])
GO
ALTER TABLE [dbo].[aspnet_PersonalizationPerUser] WITH CHECK ADD FOREIGN KEY([PathId])
REFERENCES [dbo].[aspnet_Paths] ([PathId])
GO
ALTER TABLE [dbo].[aspnet_PersonalizationPerUser] WITH CHECK ADD FOREIGN KEY([UserId])
REFERENCES [dbo].[aspnet_Users] ([UserId])
GO
ALTER TABLE [dbo].[aspnet_Profile] WITH CHECK ADD FOREIGN KEY([UserId])
REFERENCES [dbo].[aspnet_Users] ([UserId])
GO
ALTER TABLE [dbo].[aspnet_Roles] WITH CHECK ADD FOREIGN KEY([ApplicationId])
REFERENCES [dbo].[aspnet_Applications] ([ApplicationId])
GO
ALTER TABLE [dbo].[aspnet_Users] WITH CHECK ADD FOREIGN KEY([ApplicationId])
REFERENCES [dbo].[aspnet_Applications] ([ApplicationId])
GO
ALTER TABLE [dbo].[aspnet_UsersInRoles] WITH CHECK ADD FOREIGN KEY([RoleId])
REFERENCES [dbo].[aspnet_Roles] ([RoleId])
GO
ALTER TABLE [dbo].[aspnet_UsersInRoles] WITH CHECK ADD FOREIGN KEY([UserId])
REFERENCES [dbo].[aspnet_Users] ([UserId])
GO









19

5.1 Script pentru generarea tabelelor si pentru popularea acestora cu
informatii
Structura tabelului aspnet_Membership:

Tebelul aspnet_Membership:
USE [aspnetMembership]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[aspnet_Membership](
[ApplicationId] [uniqueidentifier] NOT NULL,
[UserId] [uniqueidentifier] NOT NULL,
[Password] [nvarchar](128) NOT NULL,
[PasswordFormat] [int] NOT NULL,
[PasswordSalt] [nvarchar](128) NOT NULL,
[MobilePIN] [nvarchar](16) NULL,
[Email] [nvarchar](256) NULL,
[LoweredEmail] [nvarchar](256) NULL,
20

[PasswordQuestion] [nvarchar](256) NULL,
[PasswordAnswer] [nvarchar](128) NULL,
[IsApproved] [bit] NOT NULL,
[IsLockedOut] [bit] NOT NULL,
[CreateDate] [datetime] NOT NULL,
[LastLoginDate] [datetime] NOT NULL,
[LastPasswordChangedDate] [datetime] NOT NULL,
[LastLockoutDate] [datetime] NOT NULL,
[FailedPasswordAttemptCount] [int] NOT NULL,
[FailedPasswordAttemptWindowStart] [datetime] NOT NULL,
[FailedPasswordAnswerAttemptCount] [int] NOT NULL,
[FailedPasswordAnswerAttemptWindowStart] [datetime] NOT NULL,
[Comment] [ntext] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
INSERT [dbo].[aspnet_Membership] ([ApplicationId], [UserId], [Password],
[PasswordFormat], [PasswordSalt], [MobilePIN], [Email], [LoweredEmail],
[PasswordQuestion], [PasswordAnswer], [IsApproved], [IsLockedOut], [CreateDate],
[LastLoginDate], [LastPasswordChangedDate], [LastLockoutDate],
[FailedPasswordAttemptCount], [FailedPasswordAttemptWindowStart],
[FailedPasswordAnswerAttemptCount], [FailedPasswordAnswerAttemptWindowStart], [Comment])
VALUES (N'405b687b-9f1d-445e-b437-ed964d25c604', N'd512372f-fe8d-4a43-a19d-0cf9fc825780',
N'XdxU4Hss9RUI1iS1ymsr/+bMRfo=', 1, N'YzuToaTWTl3IOrotEpyt4w==', NULL, N'a@mikon.ro',
N'a@mikon.ro', NULL, NULL, 0, 0, CAST(0x0000A01A013A00C4 AS DateTime),
CAST(0x0000A01A013B0717 AS DateTime), CAST(0x0000A34000169DF6 AS DateTime),
CAST(0xFFFF2FB300000000 AS DateTime), 0, CAST(0xFFFF2FB300000000 AS DateTime), 0,
CAST(0xFFFF2FB300000000 AS DateTime), NULL)
INSERT [dbo].[aspnet_Membership] ([ApplicationId], [UserId], [Password],
[PasswordFormat], [PasswordSalt], [MobilePIN], [Email], [LoweredEmail],
[PasswordQuestion], [PasswordAnswer], [IsApproved], [IsLockedOut], [CreateDate],
[LastLoginDate], [LastPasswordChangedDate], [LastLockoutDate],
[FailedPasswordAttemptCount], [FailedPasswordAttemptWindowStart],
[FailedPasswordAnswerAttemptCount], [FailedPasswordAnswerAttemptWindowStart], [Comment])
VALUES (N'405b687b-9f1d-445e-b437-ed964d25c604', N'5bab9789-d468-4af3-bf6b-bcceb9d458a8',
N'seHIriFzD2bb/kxZbR+R1nyD/rk=', 1, N'bYA/7YlusOFbPVx+Ud01tA==', NULL, N'ccc@mikon.ro',
N'ccc@mikon.ro', NULL, NULL, 0, 0, CAST(0x0000A01B00BC9DF0 AS DateTime),
CAST(0x0000A01B00BCC25D AS DateTime), CAST(0x0000A01B00BC9DF0 AS DateTime),
CAST(0xFFFF2FB300000000 AS DateTime), 0, CAST(0xFFFF2FB300000000 AS DateTime), 0,
CAST(0xFFFF2FB300000000 AS DateTime), NULL)
INSERT [dbo].[aspnet_Membership] ([ApplicationId], [UserId], [Password],
[PasswordFormat], [PasswordSalt], [MobilePIN], [Email], [LoweredEmail],
[PasswordQuestion], [PasswordAnswer], [IsApproved], [IsLockedOut], [CreateDate],
[LastLoginDate], [LastPasswordChangedDate], [LastLockoutDate],
[FailedPasswordAttemptCount], [FailedPasswordAttemptWindowStart],
[FailedPasswordAnswerAttemptCount], [FailedPasswordAnswerAttemptWindowStart], [Comment])
VALUES (N'405b687b-9f1d-445e-b437-ed964d25c604', N'525ce033-afaf-4add-abca-f928fc02ffda',
N'3qmBAHda07xTnGdyE/gshp7TW5o=', 1, N'5+Qje2DPhgh//5j/a9WZsw==', NULL,
N'claudiu.ionita@mikon.ro', N'claudiu.ionita@mikon.ro', NULL, NULL, 1, 0,
CAST(0x0000A01B00E488B0 AS DateTime), CAST(0x0000A01B00E544AD AS DateTime),
CAST(0x0000A01B00E5071A AS DateTime), CAST(0xFFFF2FB300000000 AS DateTime), 1,
CAST(0x0000A34000172439 AS DateTime), 0, CAST(0xFFFF2FB300000000 AS DateTime), NULL)
INSERT [dbo].[aspnet_Membership] ([ApplicationId], [UserId], [Password],
[PasswordFormat], [PasswordSalt], [MobilePIN], [Email], [LoweredEmail],
[PasswordQuestion], [PasswordAnswer], [IsApproved], [IsLockedOut], [CreateDate],
[LastLoginDate], [LastPasswordChangedDate], [LastLockoutDate],
[FailedPasswordAttemptCount], [FailedPasswordAttemptWindowStart],
[FailedPasswordAnswerAttemptCount], [FailedPasswordAnswerAttemptWindowStart], [Comment])
21

VALUES (N'405b687b-9f1d-445e-b437-ed964d25c604', N'14132ce8-8852-4dbf-8a3b-faddda06df24',
N'vSAr96DZhjfDKlAKHyI/KD28JJc=', 1, N'2dye9IQf5Y6iMlih6y7d0g==', NULL,
N'dms.administrator@mikon.ro', N'dms.administrator@mikon.ro', N'question',
N'ngi6G2mk7dWAkePIN8gQNH4/C3M=', 1, 0, CAST(0x00009A6300AB31C8 AS DateTime),
CAST(0x0000A340005A8A89 AS DateTime), CAST(0x0000A01A0085DBD9 AS DateTime),
CAST(0xFFFF2FB300000000 AS DateTime), 0, CAST(0xFFFF2FB300000000 AS DateTime), 0,
CAST(0xFFFF2FB300000000 AS DateTime), NULL)
INSERT [dbo].[aspnet_Membership] ([ApplicationId], [UserId], [Password],
[PasswordFormat], [PasswordSalt], [MobilePIN], [Email], [LoweredEmail],
[PasswordQuestion], [PasswordAnswer], [IsApproved], [IsLockedOut], [CreateDate],
[LastLoginDate], [LastPasswordChangedDate], [LastLockoutDate],
[FailedPasswordAttemptCount], [FailedPasswordAttemptWindowStart],
[FailedPasswordAnswerAttemptCount], [FailedPasswordAnswerAttemptWindowStart], [Comment])
VALUES (N'405b687b-9f1d-445e-b437-ed964d25c604', N'721d4033-7978-43d9-b008-a9e8aca4ac3a',
N'm9V/k957UjzT3ljQMO6lOQZ097Y=', 1, N'udHImhizoSKJtUUmAkhBMg==', NULL,
N'dms.client@mikon.ro', N'dms.client@mikon.ro', N'question?',
N'8p3VLNHi8MbnSWlW/Lhj/KG9Fu8=', 1, 0, CAST(0x00009C8600A0A49C AS DateTime),
CAST(0x0000A3400019A485 AS DateTime), CAST(0x0000A34000199059 AS DateTime),
CAST(0xFFFF2FB300000000 AS DateTime), 0, CAST(0xFFFF2FB300000000 AS DateTime), 0,
CAST(0xFFFF2FB300000000 AS DateTime), N'Client Account')
INSERT [dbo].[aspnet_Membership] ([ApplicationId], [UserId], [Password],
[PasswordFormat], [PasswordSalt], [MobilePIN], [Email], [LoweredEmail],
[PasswordQuestion], [PasswordAnswer], [IsApproved], [IsLockedOut], [CreateDate],
[LastLoginDate], [LastPasswordChangedDate], [LastLockoutDate],
[FailedPasswordAttemptCount], [FailedPasswordAttemptWindowStart],
[FailedPasswordAnswerAttemptCount], [FailedPasswordAnswerAttemptWindowStart], [Comment])
VALUES (N'405b687b-9f1d-445e-b437-ed964d25c604', N'df4f1533-8d99-428e-82a8-65d65e1d42d2',
N'H+5YfZp0XDuvsa3dxcs8IpzMEhs=', 1, N'0FPCCK9WDhbE4QTan2fw8Q==', NULL,
N'dms.driver@mikon.ro', N'dms.driver@mikon.ro', N'question?',
N'yviM0z+7N5XqNtXlWJD6AMYI/9w=', 1, 0, CAST(0x00009C8400EC94D8 AS DateTime),
CAST(0x0000A18C00BFE900 AS DateTime), CAST(0x00009C8400EC94D8 AS DateTime),
CAST(0xFFFF2FB300000000 AS DateTime), 0, CAST(0xFFFF2FB300000000 AS DateTime), 0,
CAST(0xFFFF2FB300000000 AS DateTime), NULL)
INSERT [dbo].[aspnet_Membership] ([ApplicationId], [UserId], [Password],
[PasswordFormat], [PasswordSalt], [MobilePIN], [Email], [LoweredEmail],
[PasswordQuestion], [PasswordAnswer], [IsApproved], [IsLockedOut], [CreateDate],
[LastLoginDate], [LastPasswordChangedDate], [LastLockoutDate],
[FailedPasswordAttemptCount], [FailedPasswordAttemptWindowStart],
[FailedPasswordAnswerAttemptCount], [FailedPasswordAnswerAttemptWindowStart], [Comment])
VALUES (N'405b687b-9f1d-445e-b437-ed964d25c604', N'93594cfe-8370-445a-9022-eeab6a54bead',
N'X+kmmWq1e30xWOMGiNunVXED0GI=', 1, N'NZfALqvIrJBMdEuTK5txBg==', NULL,
N'dms.fieldmanager@mikon.ro', N'dms.fieldmanager@mikon.ro', N'question?',
N'Bo621DoIBcXV9mcHn+KUmgseU3I=', 1, 0, CAST(0x00009C8600A6BA08 AS DateTime),
CAST(0x00009F9F00D7B92B AS DateTime), CAST(0x00009C8600A6BA08 AS DateTime),
CAST(0xFFFF2FB300000000 AS DateTime), 0, CAST(0xFFFF2FB300000000 AS DateTime), 0,
CAST(0xFFFF2FB300000000 AS DateTime), NULL)
INSERT [dbo].[aspnet_Membership] ([ApplicationId], [UserId], [Password],
[PasswordFormat], [PasswordSalt], [MobilePIN], [Email], [LoweredEmail],
[PasswordQuestion], [PasswordAnswer], [IsApproved], [IsLockedOut], [CreateDate],
[LastLoginDate], [LastPasswordChangedDate], [LastLockoutDate],
[FailedPasswordAttemptCount], [FailedPasswordAttemptWindowStart],
[FailedPasswordAnswerAttemptCount], [FailedPasswordAnswerAttemptWindowStart], [Comment])
VALUES (N'405b687b-9f1d-445e-b437-ed964d25c604', N'b55abc91-954d-4eb6-aee1-d5499daa763b',
N'vQAutHEJRkhz2f6jLeAsnscrPoc=', 1, N'hnEI1wxjV6vC+6uftp81Cw==', NULL,
N'dms.inspector@mikon.ro', N'dms.inspector@mikon.ro', N'question?',
N'HyLRnCAr22fqFHcyNkxYln/EPHY=', 1, 0, CAST(0x00009C8000AC5A44 AS DateTime),
CAST(0x0000A2170085416C AS DateTime), CAST(0x00009C8000AC5A44 AS DateTime),
22

CAST(0xFFFF2FB300000000 AS DateTime), 0, CAST(0xFFFF2FB300000000 AS DateTime), 0,
CAST(0xFFFF2FB300000000 AS DateTime), NULL)
INSERT [dbo].[aspnet_Membership] ([ApplicationId], [UserId], [Password],
[PasswordFormat], [PasswordSalt], [MobilePIN], [Email], [LoweredEmail],
[PasswordQuestion], [PasswordAnswer], [IsApproved], [IsLockedOut], [CreateDate],
[LastLoginDate], [LastPasswordChangedDate], [LastLockoutDate],
[FailedPasswordAttemptCount], [FailedPasswordAttemptWindowStart],
[FailedPasswordAnswerAttemptCount], [FailedPasswordAnswerAttemptWindowStart], [Comment])
VALUES (N'405b687b-9f1d-445e-b437-ed964d25c604', N'418698cf-84ed-4943-9027-e7efc0f4573e',
N'szbAMafM4M9GpW+bLJb5FBjUk7w=', 1, N'szxOfmvDy0MtX48E8wk1uQ==', NULL,
N'dms.labmanager@mikon.ro', N'dms.labmanager@mikon.ro', N'question?',
N'hso+ueZVqsN6cc1oCuQ4CkN2h88=', 1, 0, CAST(0x00009C8600A73D48 AS DateTime),
CAST(0x0000A26500EB5FE3 AS DateTime), CAST(0x00009C8600A73D48 AS DateTime),
CAST(0xFFFF2FB300000000 AS DateTime), 0, CAST(0xFFFF2FB300000000 AS DateTime), 0,
CAST(0xFFFF2FB300000000 AS DateTime), NULL)
INSERT [dbo].[aspnet_Membership] ([ApplicationId], [UserId], [Password],
[PasswordFormat], [PasswordSalt], [MobilePIN], [Email], [LoweredEmail],
[PasswordQuestion], [PasswordAnswer], [IsApproved], [IsLockedOut], [CreateDate],
[LastLoginDate], [LastPasswordChangedDate], [LastLockoutDate],
[FailedPasswordAttemptCount], [FailedPasswordAttemptWindowStart],
[FailedPasswordAnswerAttemptCount], [FailedPasswordAnswerAttemptWindowStart], [Comment])
VALUES (N'405b687b-9f1d-445e-b437-ed964d25c604', N'a695fbc0-8295-4582-bcba-e8a677830384',
N'qZNIks0OB8jteH8weLpjCLqH3VQ=', 1, N'k0Buozc9AXftgcqM0Xamjw==', NULL,
N'dms.labtechnician@mikon.ro', N'dms.labtechnician@mikon.ro', N'question?',
N'KjfK9JbDUkiZh0/giF98TX+LIL4=', 1, 0, CAST(0x00009C8600B4201C AS DateTime),
CAST(0x00009EBB00C45912 AS DateTime), CAST(0x00009C8600B4201C AS DateTime),
CAST(0xFFFF2FB300000000 AS DateTime), 0, CAST(0xFFFF2FB300000000 AS DateTime), 0,
CAST(0xFFFF2FB300000000 AS DateTime), NULL)
INSERT [dbo].[aspnet_Membership] ([ApplicationId], [UserId], [Password],
[PasswordFormat], [PasswordSalt], [MobilePIN], [Email], [LoweredEmail],
[PasswordQuestion], [PasswordAnswer], [IsApproved], [IsLockedOut], [CreateDate],
[LastLoginDate], [LastPasswordChangedDate], [LastLockoutDate],
[FailedPasswordAttemptCount], [FailedPasswordAttemptWindowStart],
[FailedPasswordAnswerAttemptCount], [FailedPasswordAnswerAttemptWindowStart], [Comment])
VALUES (N'405b687b-9f1d-445e-b437-ed964d25c604', N'c04ff279-2029-42f4-9870-a59be06cdf4c',
N'FSCAQ+5CtNqSLU1ypipuHRzNge0=', 1, N'6i7PjyQyYoAj10QdqHfVCA==', NULL,
N'dms.techmanager@mikon.ro', N'dms.techmanager@mikon.ro', N'question?',
N'8OJwi3jGOVrcA1FWGMmwsq3LCFs=', 1, 0, CAST(0x00009C8600B36BA4 AS DateTime),
CAST(0x00009ECC00974DC5 AS DateTime), CAST(0x00009C8600B36BA4 AS DateTime),
CAST(0xFFFF2FB300000000 AS DateTime), 0, CAST(0xFFFF2FB300000000 AS DateTime), 0,
CAST(0xFFFF2FB300000000 AS DateTime), NULL)
INSERT [dbo].[aspnet_Membership] ([ApplicationId], [UserId], [Password],
[PasswordFormat], [PasswordSalt], [MobilePIN], [Email], [LoweredEmail],
[PasswordQuestion], [PasswordAnswer], [IsApproved], [IsLockedOut], [CreateDate],
[LastLoginDate], [LastPasswordChangedDate], [LastLockoutDate],
[FailedPasswordAttemptCount], [FailedPasswordAttemptWindowStart],
[FailedPasswordAnswerAttemptCount], [FailedPasswordAnswerAttemptWindowStart], [Comment])
VALUES (N'405b687b-9f1d-445e-b437-ed964d25c604', N'36539b16-1e78-4a03-9336-3f2ae76efe2a',
N'F/kY7J1kHNyWwewBnmbXFRXje9M=', 1, N'8nmj1BDqpEmtu5jsn+4QWQ==', NULL,
N'ioan.podaru@mikon.ro', N'ioan.podaru@mikon.ro', N'question?',
N'RzFmYj21X67TLwqlB70tdRDPyCA=', 1, 0, CAST(0x00009C8600A10E14 AS DateTime),
CAST(0x0000A1BD00E7C1A4 AS DateTime), CAST(0x00009C8600A10E14 AS DateTime),
CAST(0xFFFF2FB300000000 AS DateTime), 0, CAST(0xFFFF2FB300000000 AS DateTime), 0,
CAST(0xFFFF2FB300000000 AS DateTime), N'Office Account')
INSERT [dbo].[aspnet_Membership] ([ApplicationId], [UserId], [Password],
[PasswordFormat], [PasswordSalt], [MobilePIN], [Email], [LoweredEmail],
[PasswordQuestion], [PasswordAnswer], [IsApproved], [IsLockedOut], [CreateDate],
[LastLoginDate], [LastPasswordChangedDate], [LastLockoutDate],
23

[FailedPasswordAttemptCount], [FailedPasswordAttemptWindowStart],
[FailedPasswordAnswerAttemptCount], [FailedPasswordAnswerAttemptWindowStart], [Comment])
VALUES (N'405b687b-9f1d-445e-b437-ed964d25c604', N'3212c4b1-3c2b-4234-86f6-a9abe89a0f33',
N'ND8dImHnMojBNvA0P3XEPf7bDps=', 1, N'G1vl0GqvlNlX5h/e44FnqA==', NULL,
N'ionut.podaru@mikon.ro', N'ionut.podaru@mikon.ro', NULL, NULL, 0, 0,
CAST(0x0000A01B00BDC414 AS DateTime), CAST(0x0000A01B00DD125F AS DateTime),
CAST(0x0000A01B00DDB37D AS DateTime), CAST(0xFFFF2FB300000000 AS DateTime), 0,
CAST(0xFFFF2FB300000000 AS DateTime), 0, CAST(0xFFFF2FB300000000 AS DateTime), NULL)
INSERT [dbo].[aspnet_Membership] ([ApplicationId], [UserId], [Password],
[PasswordFormat], [PasswordSalt], [MobilePIN], [Email], [LoweredEmail],
[PasswordQuestion], [PasswordAnswer], [IsApproved], [IsLockedOut], [CreateDate],
[LastLoginDate], [LastPasswordChangedDate], [LastLockoutDate],
[FailedPasswordAttemptCount], [FailedPasswordAttemptWindowStart],
[FailedPasswordAnswerAttemptCount], [FailedPasswordAnswerAttemptWindowStart], [Comment])
VALUES (N'405b687b-9f1d-445e-b437-ed964d25c604', N'aefd26ef-faca-4f5a-a0f1-8040e2a1b0c0',
N'3i7eot5Iy4kCd/5+H5D4r0mWMFI=', 1, N'zeSF5xuna2WsIHERcSjn9w==', NULL,
N'office@mikon.ro', N'office@mikon.ro', NULL, NULL, 1, 0, CAST(0x0000A01B00EDDE24 AS
DateTime), CAST(0x0000A01B00EDE9E3 AS DateTime), CAST(0x0000A01B00EDDE24 AS DateTime),
CAST(0xFFFF2FB300000000 AS DateTime), 0, CAST(0xFFFF2FB300000000 AS DateTime), 0,
CAST(0xFFFF2FB300000000 AS DateTime), NULL)
ALTER TABLE [dbo].[aspnet_Membership] ADD PRIMARY KEY NONCLUSTERED
(
[UserId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF,
IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON
[PRIMARY]
GO
ALTER TABLE [dbo].[aspnet_Membership] ADD DEFAULT ((0)) FOR [PasswordFormat]
GO
ALTER TABLE [dbo].[aspnet_Membership] WITH CHECK ADD FOREIGN KEY([ApplicationId])
REFERENCES [dbo].[aspnet_Applications] ([ApplicationId])
GO
ALTER TABLE [dbo].[aspnet_Membership] WITH CHECK ADD FOREIGN KEY([UserId])
REFERENCES [dbo].[aspnet_Users] ([UserId])
GO

Tabelul aspnet_Users:
USE [aspnetMembership]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[aspnet_Users](
[ApplicationId] [uniqueidentifier] NOT NULL,
[UserId] [uniqueidentifier] NOT NULL,
[UserName] [nvarchar](256) NOT NULL,
[LoweredUserName] [nvarchar](256) NOT NULL,
[MobileAlias] [nvarchar](16) NULL,
[IsAnonymous] [bit] NOT NULL,
[LastActivityDate] [datetime] NOT NULL
) ON [PRIMARY]

GO
INSERT [dbo].[aspnet_Users] ([ApplicationId], [UserId], [UserName], [LoweredUserName],
[MobileAlias], [IsAnonymous], [LastActivityDate]) VALUES (N'405b687b-9f1d-445e-b437-
24

ed964d25c604', N'd512372f-fe8d-4a43-a19d-0cf9fc825780', N'a', N'a', NULL, 0,
CAST(0x0000A3400032C32F AS DateTime))
INSERT [dbo].[aspnet_Users] ([ApplicationId], [UserId], [UserName], [LoweredUserName],
[MobileAlias], [IsAnonymous], [LastActivityDate]) VALUES (N'405b687b-9f1d-445e-b437-
ed964d25c604', N'525ce033-afaf-4add-abca-f928fc02ffda', N'aaa', N'aaa', NULL, 0,
CAST(0x0000A3400032C32F AS DateTime))
INSERT [dbo].[aspnet_Users] ([ApplicationId], [UserId], [UserName], [LoweredUserName],
[MobileAlias], [IsAnonymous], [LastActivityDate]) VALUES (N'405b687b-9f1d-445e-b437-
ed964d25c604', N'14132ce8-8852-4dbf-8a3b-faddda06df24', N'administrator',
N'administrator', NULL, 0, CAST(0x0000A340005A8CD5 AS DateTime))
INSERT [dbo].[aspnet_Users] ([ApplicationId], [UserId], [UserName], [LoweredUserName],
[MobileAlias], [IsAnonymous], [LastActivityDate]) VALUES (N'405b687b-9f1d-445e-b437-
ed964d25c604', N'5bab9789-d468-4af3-bf6b-bcceb9d458a8', N'ccc', N'ccc', NULL, 0,
CAST(0x0000A3400032C32F AS DateTime))
INSERT [dbo].[aspnet_Users] ([ApplicationId], [UserId], [UserName], [LoweredUserName],
[MobileAlias], [IsAnonymous], [LastActivityDate]) VALUES (N'405b687b-9f1d-445e-b437-
ed964d25c604', N'721d4033-7978-43d9-b008-a9e8aca4ac3a', N'client', N'client', NULL, 0,
CAST(0x0000A3400032C33A AS DateTime))
INSERT [dbo].[aspnet_Users] ([ApplicationId], [UserId], [UserName], [LoweredUserName],
[MobileAlias], [IsAnonymous], [LastActivityDate]) VALUES (N'405b687b-9f1d-445e-b437-
ed964d25c604', N'3212c4b1-3c2b-4234-86f6-a9abe89a0f33', N'ddd', N'ddd', NULL, 0,
CAST(0x0000A3400032C330 AS DateTime))
INSERT [dbo].[aspnet_Users] ([ApplicationId], [UserId], [UserName], [LoweredUserName],
[MobileAlias], [IsAnonymous], [LastActivityDate]) VALUES (N'405b687b-9f1d-445e-b437-
ed964d25c604', N'df4f1533-8d99-428e-82a8-65d65e1d42d2', N'driver', N'driver', NULL, 0,
CAST(0x0000A34000334442 AS DateTime))
INSERT [dbo].[aspnet_Users] ([ApplicationId], [UserId], [UserName], [LoweredUserName],
[MobileAlias], [IsAnonymous], [LastActivityDate]) VALUES (N'405b687b-9f1d-445e-b437-
ed964d25c604', N'93594cfe-8370-445a-9022-eeab6a54bead', N'fieldmanager', N'fieldmanager',
NULL, 0, CAST(0x0000A34000334442 AS DateTime))
INSERT [dbo].[aspnet_Users] ([ApplicationId], [UserId], [UserName], [LoweredUserName],
[MobileAlias], [IsAnonymous], [LastActivityDate]) VALUES (N'405b687b-9f1d-445e-b437-
ed964d25c604', N'b55abc91-954d-4eb6-aee1-d5499daa763b', N'inspector', N'inspector', NULL,
0, CAST(0x0000A34000334442 AS DateTime))
INSERT [dbo].[aspnet_Users] ([ApplicationId], [UserId], [UserName], [LoweredUserName],
[MobileAlias], [IsAnonymous], [LastActivityDate]) VALUES (N'405b687b-9f1d-445e-b437-
ed964d25c604', N'418698cf-84ed-4943-9027-e7efc0f4573e', N'labmanager', N'labmanager',
NULL, 0, CAST(0x0000A34000334443 AS DateTime))
INSERT [dbo].[aspnet_Users] ([ApplicationId], [UserId], [UserName], [LoweredUserName],
[MobileAlias], [IsAnonymous], [LastActivityDate]) VALUES (N'405b687b-9f1d-445e-b437-
ed964d25c604', N'a695fbc0-8295-4582-bcba-e8a677830384', N'labtechnician',
N'labtechnician', NULL, 0, CAST(0x0000A34000334443 AS DateTime))
INSERT [dbo].[aspnet_Users] ([ApplicationId], [UserId], [UserName], [LoweredUserName],
[MobileAlias], [IsAnonymous], [LastActivityDate]) VALUES (N'405b687b-9f1d-445e-b437-
ed964d25c604', N'36539b16-1e78-4a03-9336-3f2ae76efe2a', N'office', N'office', NULL, 0,
CAST(0x0000A34000334443 AS DateTime))
INSERT [dbo].[aspnet_Users] ([ApplicationId], [UserId], [UserName], [LoweredUserName],
[MobileAlias], [IsAnonymous], [LastActivityDate]) VALUES (N'405b687b-9f1d-445e-b437-
ed964d25c604', N'c04ff279-2029-42f4-9870-a59be06cdf4c', N'techmanager', N'techmanager',
NULL, 0, CAST(0x0000A34000334444 AS DateTime))
INSERT [dbo].[aspnet_Users] ([ApplicationId], [UserId], [UserName], [LoweredUserName],
[MobileAlias], [IsAnonymous], [LastActivityDate]) VALUES (N'405b687b-9f1d-445e-b437-
ed964d25c604', N'aefd26ef-faca-4f5a-a0f1-8040e2a1b0c0', N'test', N'test', NULL, 0,
CAST(0x0000A3400032C331 AS DateTime))
ALTER TABLE [dbo].[aspnet_Users] ADD PRIMARY KEY NONCLUSTERED
(
[UserId] ASC
25

)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF,
IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON
[PRIMARY]
GO
ALTER TABLE [dbo].[aspnet_Users] ADD DEFAULT (newid()) FOR [UserId]
GO
ALTER TABLE [dbo].[aspnet_Users] ADD DEFAULT (NULL) FOR [MobileAlias]
GO
ALTER TABLE [dbo].[aspnet_Users] ADD DEFAULT ((0)) FOR [IsAnonymous]
GO
ALTER TABLE [dbo].[aspnet_Users] WITH CHECK ADD FOREIGN KEY([ApplicationId])
REFERENCES [dbo].[aspnet_Applications] ([ApplicationId])
GO


6. Descrierea view-urilor. Codul sql pentru crearea lor

Afisare email,data ultimei logari,data cand au fost creati utilizatorii care detin membership:
CREATE VIEW [dbo].[View_1]
AS
SELECT LastLoginDate, Email, IsApproved, CreateDate
FROM dbo.aspnet_Membership

GO

Afisarea adreselor de mail din membership pe baza username din tabela aspnet_Users cu contitia
ca isAproved = true:
USE [aspnetMembership]
26

GO

SET QUOTED_IDENTIFIER ON
GO

CREATE VIEW [dbo].[View_2]
AS
SELECT dbo.aspnet_Users.UserName, dbo.aspnet_Users.LastActivityDate,
dbo.aspnet_Membership.Email
FROM dbo.aspnet_Membership INNER JOIN
dbo.aspnet_Users ON dbo.aspnet_Membership.UserId =
dbo.aspnet_Users.UserId AND dbo.aspnet_Membership.IsApproved = 1

GO

Afisarea username a utilizatorilor si a rolului care acesta il detine pe baza legaturilor intre tabele
aspnet_Users si aspnet_Roles cu ajutorul tabelei aspnet_ UsersInRoles:
USE [aspnetMembership]
GO
CREATE VIEW [dbo].[View_3]
AS
SELECT dbo.aspnet_Users.ApplicationId, dbo.aspnet_Users.UserName,
dbo.aspnet_Roles.RoleName, dbo.aspnet_Roles.LoweredRoleName, dbo.aspnet_Roles.RoleId
FROM dbo.aspnet_Users INNER JOIN
dbo.aspnet_UsersInRoles ON dbo.aspnet_Users.UserId =
dbo.aspnet_UsersInRoles.UserId INNER JOIN
dbo.aspnet_Roles ON dbo.aspnet_UsersInRoles.RoleId =
dbo.aspnet_Roles.RoleId

GO
27




Afisarea utilizatorilor si a proprietatilor acestora in functie de data ultimei modificari ordonat
crescator:
USE [aspnetMembership]
GO

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE VIEW [dbo].[View_4]
AS
SELECT TOP (100) PERCENT dbo.aspnet_Users.UserName,
dbo.aspnet_Profile.PropertyNames, dbo.aspnet_Profile.LastUpdatedDate
FROM dbo.aspnet_Users INNER JOIN
dbo.aspnet_Profile ON dbo.aspnet_Users.UserId =
dbo.aspnet_Profile.UserId
ORDER BY dbo.aspnet_Profile.LastUpdatedDate

GO

28



Afisarea utilizatorului din Users, rolului acestuia din Roles ,data ultimei modificari si a numelui
proprietatatii din proprietati cu conditia ca ele sa fie afisate in ordine descrescatoare dupa data ultimei
modificari:
USE [aspnetMembership]
GO

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE VIEW [dbo].[View_6]
AS
SELECT TOP (100) PERCENT dbo.aspnet_Roles.RoleName, dbo.aspnet_Users.UserName,
dbo.aspnet_Profile.PropertyNames, dbo.aspnet_Profile.LastUpdatedDate
FROM dbo.aspnet_Profile INNER JOIN
dbo.aspnet_Users ON dbo.aspnet_Profile.UserId =
dbo.aspnet_Users.UserId INNER JOIN
dbo.aspnet_UsersInRoles ON dbo.aspnet_Users.UserId =
dbo.aspnet_UsersInRoles.UserId INNER JOIN
dbo.aspnet_Roles ON dbo.aspnet_UsersInRoles.RoleId =
dbo.aspnet_Roles.RoleId
ORDER BY dbo.aspnet_Profile.LastUpdatedDate DESC

GO

29


















30


7. Concluzii



Acest proiect m-a ajutat sa imi imbogatesc cunostintele acumulate de-a lungul
cursurilor si seminariilor de base de date reusind sa imbin teoria predata cu
practica. De asemenea am acumulat cunostinte noi documentandu-ma si
adaugandu-le in acest proiect.
In realizarea acestui proiect am reusit sa creez o baza de date pentru
gestionarea utilizatorilor unei platforme online ce poate fi folosita de orice
provider care doreste sa aiba o baza de date atasata siteu-lui.Am realizat cat
de importanta este existententa unei baze de date in cadrul unei firme sau in
cadrul unei companii cu foarte multi angajati.












31

8. Bibliografie

1.Baze de date-curs-Prof.Mariana Marinescu
2. http://ro.wikipedia.org/wiki/PostgreSQL
3. http://databaseanswers.org/data_models/index.htm
4. http://msdn.microsoft.com/en-us/library/cc645993.aspx
5. http://ro.wikipedia.org/wiki/Baz%C4%83_de_date
6. http://ro.wikipedia.org/wiki/Microsoft_SQL_Server
7. http://ro.wikipedia.org/wiki/SQL