├── AS Keyword.sql
├── ASSIGNMENT1.docx
├── Assignment1_dbms.txt
├── Between_and_logical Operators.sql
├── Create_DropDatabase.sql
├── DatabasePlan.sql
├── Distinct Keyword.sql
├── Domain Constraints with check statement.sql
├── ERD-InvConSys.PNG
├── FirstTestReport
├── FirstTestReport.sln
└── FirstTestReport
│ ├── FirstTestReport.rptproj
│ ├── FirstTestReport.rptproj.rsuser
│ ├── RealEstate.rds
│ ├── Report1.rdl
│ ├── Report1.rdl.data
│ └── bin
│ └── Debug
│ ├── RealEstate.rds
│ ├── Report1.rdl
│ └── build.obj
├── Labs
├── DBMS LAB2.docx
├── DBMS LAB3.docx
├── DBMS LAB7.docx
├── data_definition.sql
├── lab1.sql
├── lab4.sql
└── lab6.sql
├── Like SQL.sql
├── Nested Queries.sql
├── No Action Refrential integrity constraints.sql
├── Numeric data Types.sql
├── PerdaySalary.sql
├── README.md
├── Set Null Refrential Integrity constraints.sql
├── String Data Types.sql
├── TableCreation.sql
├── erd.PNG
├── refrential integrity cascade constraints.sql
└── stored Procedures.sql
/AS Keyword.sql:
--------------------------------------------------------------------------------
1 | select CurrentSalary as salary from staff /*change column name*/
--------------------------------------------------------------------------------
/ASSIGNMENT1.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/muhammadfaraz6640/Database-Management-System/51e5c5104933389f884abf2c9463d4b1ed31bd73/ASSIGNMENT1.docx
--------------------------------------------------------------------------------
/Assignment1_dbms.txt:
--------------------------------------------------------------------------------
1 | -----Wards
2 | Ward_id int primary key identity
3 | Ward_Name nvarchar(50)
4 | Beds nvarchar(50)
5 | Location nvarchar(50)
6 | Telephone_Extension BIGINT
7 |
8 |
9 | ---------Bed
10 | Bed_Number(PK)
11 | Ward_id(FK)
12 | ------Staff
13 | staff_Number
14 | First_Name
15 | Last_Name
16 | Address
17 | Ph_Number
18 | Date_of_Birth
19 | Gender
20 | NIN
21 | Position
22 | Cuurent_Salary
23 | Salary_Scale
24 | Shift
25 | Ward_id
26 | Qualification_id(FK)
27 | Experience_id(FK)
28 |
29 | -----Qualification
30 | Qualification_id(PK)
31 | date_of_Qualification
32 | Type_of_Qualification
33 | Institute_qualification
34 |
35 | -----Experience
36 | Experience_id(PK)
37 | Position
38 | Start_Date
39 | Finish_Date
40 | Organization
41 |
42 | -------Patient
43 | Patient_id
44 | Patient_FirstName
45 | Patient_LastName
46 | Patient_Address
47 | Patient_DateBirth
48 | Patient_gender
49 | Patient_Martital_Status
50 | Patient_Date_Regd
51 | Patient_Relative_id(FK)
52 | LocalDoctor_id(FK)
53 |
54 | -------Patient_NextKin
55 | Patient_Relative_id
56 | FullName
57 | Relation_with_Patient
58 | Address
59 | Telephone
60 |
61 | --------LocalDoctors
62 | LocalDoctor_id
63 | Doctor_FUllName
64 | Doctor_ClinicNo
65 | Doctor_Address
66 | Doctor_Phone
67 |
68 | --------Appointments
69 | Appointment_id(PK)
70 | Patient_id(FK)
71 | staff_Number(FK)
72 | Date
73 | time
74 | Examination_RoomNo
75 |
76 | ---------WardDetails
77 | WD_id(PK)
78 | Ward_id(FK)
79 | Patient_id(FK)
80 | Date_On_WaitList
81 | Expected_Stay_Days
82 | Date_Admitted
83 | Date_Leave
84 | Actual_Date_Leave
85 | Bed_id
86 |
87 | ---------Drug
88 | Drug_Number(PK)
89 | Drug_name
90 | Drug_Description
91 | Dosage
92 | Method_intake
93 | Units_Per_unit
94 | Start_date
95 | Finish_Date
96 |
97 | ---------Medication
98 | Medication_id(PK)
99 | Patient_id(FK)
100 | Drug_id(FK)
101 | Ward_id(FK)
102 | Bed_id(FK)
103 |
104 |
105 | ----------Sur_NonSur_Items
106 | Item_Number(PK)
107 | Item_Type-->can be surgical and non surgical
108 | Item_name
109 | Item_Description
110 | Qty_Stock
111 | Reorder_level
112 | Cost_per_Item
113 |
114 | ----------Pharmaceutical
115 | Pharmaceutical_id(PK)
116 | Drug_Number(FK)
117 | Qty_Stock
118 | Reorder_level
119 | Cost_per_Item
120 |
121 | ----------Requistion_request
122 | Riquistion_number(PK)
123 | Drug_id(FK)
124 | Qty_drug
125 | req_date
126 | Staff_id(FK)
127 |
128 | -----------Requistion_Accepted
129 | RAccept_id(PK)
130 | Riquistion_number(FK)
131 | staff_id(FK)-->recieving_person
132 |
133 | ------------Suppliers
134 | Supplier_id(PK)
135 | Supply_Type-->can be surgical , non-surgical and pharma
136 | Supplier_Name
137 | Supplier_Address
138 | Supplier_Phone
139 | Supplier_Fax
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
--------------------------------------------------------------------------------
/Between_and_logical Operators.sql:
--------------------------------------------------------------------------------
1 | select * from staff where CurrentSalary between 15000 AND 25000
2 | select * from staff where CurrentSalary >= 15000 AND CurrentSalary <= 25000
3 | select * from staff where StaffShift = 'morning' OR Gender = 'female'
--------------------------------------------------------------------------------
/Create_DropDatabase.sql:
--------------------------------------------------------------------------------
1 | create database InventoryControl /* command to create the database */
2 |
3 | Drop database InventoryControl /* command to delete the database */
4 |
5 | /* select the query and press ctrl+e to execute the query */
6 |
7 |
--------------------------------------------------------------------------------
/DatabasePlan.sql:
--------------------------------------------------------------------------------
1 | /*-----------------------inverntory Control System-----------------
2 |
3 | 1)Admin
4 | Aid , Aname , Email , password , Status , role
5 | 2)Login
6 | Lid , Email , password , role
7 | 3)Categories
8 | Cid , Catname
9 | 4)Product
10 | Pid , Cid , PName , Barcode , Expiry
11 | 5)PurchaseInvoice (from Supplier)
12 | PIid , Pid , Qty , PerUnitPrice , Total
13 | 6)Supplier
14 | Sid , SName , SContact , SAddress , SNtn , Status
15 | 7) Workers
16 | Wid , WName , WAddress , WContact , WEmail , WDesignation , WPassword
17 | 8)ProductPricing
18 | PPid , PIid , ProfitPercent , DiscountPercent , FinalPrice
19 | 9)Sales
20 | SLid , Pid , PQty , PIid , DiscountPrice , TotalPriceEach , GrossTotal
21 | 10)Bill
22 | Bid , SLid
23 |
24 | 11) History
25 | Hid , Wid , TimeLogin , TimeLogout
26 |
27 | */
--------------------------------------------------------------------------------
/Distinct Keyword.sql:
--------------------------------------------------------------------------------
1 | select distinct CurrentSalary from staff /*eliminate duplicate if use distinct*/
2 |
--------------------------------------------------------------------------------
/Domain Constraints with check statement.sql:
--------------------------------------------------------------------------------
1 | create table Domain_Constraints(
2 | sex char not null
3 | check(sex IN ('M','F'))
4 | )
5 |
6 | insert into Domain_Constraints values('g') /*The INSERT statement conflicted with the CHECK constraint "CK__Domain_Cons__sex__6383C8BA" hence terminated*/
7 |
8 | insert into Domain_Constraints values('M')
9 |
10 | select * from Domain_Constraints
11 | create domain sex_type as char check (value in ('m','f')); /*now sex_type becomes restricted datatype*/
12 |
--------------------------------------------------------------------------------
/ERD-InvConSys.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/muhammadfaraz6640/Database-Management-System/51e5c5104933389f884abf2c9463d4b1ed31bd73/ERD-InvConSys.PNG
--------------------------------------------------------------------------------
/FirstTestReport/FirstTestReport.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.28307.1022
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{F14B399A-7131-4C87-9E4B-1186C45EF12D}") = "FirstTestReport", "FirstTestReport\FirstTestReport.rptproj", "{84B2DBB8-2D86-4CE4-81DE-E9BDBAC4B303}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Default = Debug|Default
11 | DebugLocal|Default = DebugLocal|Default
12 | Release|Default = Release|Default
13 | EndGlobalSection
14 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
15 | {84B2DBB8-2D86-4CE4-81DE-E9BDBAC4B303}.Debug|Default.ActiveCfg = Debug
16 | {84B2DBB8-2D86-4CE4-81DE-E9BDBAC4B303}.Debug|Default.Build.0 = Debug
17 | {84B2DBB8-2D86-4CE4-81DE-E9BDBAC4B303}.Debug|Default.Deploy.0 = Debug
18 | {84B2DBB8-2D86-4CE4-81DE-E9BDBAC4B303}.DebugLocal|Default.ActiveCfg = DebugLocal
19 | {84B2DBB8-2D86-4CE4-81DE-E9BDBAC4B303}.DebugLocal|Default.Build.0 = DebugLocal
20 | {84B2DBB8-2D86-4CE4-81DE-E9BDBAC4B303}.Release|Default.ActiveCfg = Release
21 | {84B2DBB8-2D86-4CE4-81DE-E9BDBAC4B303}.Release|Default.Build.0 = Release
22 | {84B2DBB8-2D86-4CE4-81DE-E9BDBAC4B303}.Release|Default.Deploy.0 = Release
23 | EndGlobalSection
24 | GlobalSection(SolutionProperties) = preSolution
25 | HideSolutionNode = FALSE
26 | EndGlobalSection
27 | GlobalSection(ExtensibilityGlobals) = postSolution
28 | SolutionGuid = {CB7301D8-B5DB-4927-B727-4102BAA9C924}
29 | EndGlobalSection
30 | EndGlobal
31 |
--------------------------------------------------------------------------------
/FirstTestReport/FirstTestReport/FirstTestReport.rptproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | bin\Debug
6 | 2
7 | False
8 | False
9 | SSRS2016
10 | Win32
11 | FirstTestReport
12 | Datasets
13 | Data Sources
14 | Report Parts
15 | http://localhost/reportserver
16 |
17 |
18 | DebugLocal
19 | bin\DebugLocal
20 | 2
21 | False
22 | False
23 | SSRS2016
24 | Win32
25 | FirstTestReport
26 | Datasets
27 | Data Sources
28 | Report Parts
29 | http://localhost/reportserver
30 |
31 |
32 | Release
33 | bin\Release
34 | 2
35 | False
36 | False
37 | SSRS2016
38 | Win32
39 | FirstTestReport
40 | Datasets
41 | Data Sources
42 | Report Parts
43 | http://localhost/reportserver
44 |
45 |
46 | $base64$PFNvdXJjZUNvbnRyb2xJbmZvIHhtbG5zOnhzZD0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEiIHhtbG5zOnhzaT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEtaW5zdGFuY2UiIHhtbG5zOmRkbDI9Imh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vYW5hbHlzaXNzZXJ2aWNlcy8yMDAzL2VuZ2luZS8yIiB4bWxuczpkZGwyXzI9Imh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vYW5hbHlzaXNzZXJ2aWNlcy8yMDAzL2VuZ2luZS8yLzIiIHhtbG5zOmRkbDEwMF8xMDA9Imh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vYW5hbHlzaXNzZXJ2aWNlcy8yMDA4L2VuZ2luZS8xMDAvMTAwIiB4bWxuczpkZGwyMDA9Imh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vYW5hbHlzaXNzZXJ2aWNlcy8yMDEwL2VuZ2luZS8yMDAiIHhtbG5zOmRkbDIwMF8yMDA9Imh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vYW5hbHlzaXNzZXJ2aWNlcy8yMDEwL2VuZ2luZS8yMDAvMjAwIiB4bWxuczpkZGwzMDA9Imh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vYW5hbHlzaXNzZXJ2aWNlcy8yMDExL2VuZ2luZS8zMDAiIHhtbG5zOmRkbDMwMF8zMDA9Imh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vYW5hbHlzaXNzZXJ2aWNlcy8yMDExL2VuZ2luZS8zMDAvMzAwIiB4bWxuczpkZGw0MDA9Imh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vYW5hbHlzaXNzZXJ2aWNlcy8yMDEyL2VuZ2luZS80MDAiIHhtbG5zOmRkbDQwMF80MDA9Imh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vYW5hbHlzaXNzZXJ2aWNlcy8yMDEyL2VuZ2luZS80MDAvNDAwIiB4bWxuczpkZGw1MDA9Imh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vYW5hbHlzaXNzZXJ2aWNlcy8yMDEzL2VuZ2luZS81MDAiIHhtbG5zOmRkbDUwMF81MDA9Imh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vYW5hbHlzaXNzZXJ2aWNlcy8yMDEzL2VuZ2luZS81MDAvNTAwIiB4bWxuczpkd2Q9Imh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vRGF0YVdhcmVob3VzZS9EZXNpZ25lci8xLjAiPg0KICA8RW5hYmxlZD5mYWxzZTwvRW5hYmxlZD4NCiAgPFByb2plY3ROYW1lPjwvUHJvamVjdE5hbWU+DQogIDxBdXhQYXRoPjwvQXV4UGF0aD4NCiAgPExvY2FsUGF0aD48L0xvY2FsUGF0aD4NCiAgPFByb3ZpZGVyPjwvUHJvdmlkZXI+DQo8L1NvdXJjZUNvbnRyb2xJbmZvPg==
47 | @(DataSource)
48 | @(DataSet)
49 | @(Report)
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/FirstTestReport/FirstTestReport/FirstTestReport.rptproj.rsuser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/muhammadfaraz6640/Database-Management-System/51e5c5104933389f884abf2c9463d4b1ed31bd73/FirstTestReport/FirstTestReport/FirstTestReport.rptproj.rsuser
--------------------------------------------------------------------------------
/FirstTestReport/FirstTestReport/RealEstate.rds:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | SQL
5 |
6 |
7 | e215e435-42b6-49b1-9bf6-62efe1c0effb
8 |
--------------------------------------------------------------------------------
/FirstTestReport/FirstTestReport/Report1.rdl:
--------------------------------------------------------------------------------
1 |
2 |
3 | Segoe UI
4 | 0
5 |
6 |
7 |
8 | SQL
9 | Data Source=MUHAMMADFARAZAN\SQLEXPRESS;Initial Catalog=RealEstateManagementSystem
10 | true
11 |
12 | Integrated
13 | 727b24a3-5e57-4733-8192-a502c624c1bb
14 |
15 |
16 |
17 |
18 |
19 | DataSource1
20 | SELECT Property.City, Property.Location, Property.Rooms, Property.Demand, Seller.Name, Seller.Gender, Seller.Contact, Property.Description
21 | FROM Property INNER JOIN
22 | Seller ON Property.Sid = Seller.Sid
23 |
24 |
25 |
26 | City
27 | System.String
28 |
29 |
30 | Location
31 | System.String
32 |
33 |
34 | Rooms
35 | System.String
36 |
37 |
38 | Demand
39 | System.String
40 |
41 |
42 | Name
43 | System.String
44 |
45 |
46 | Gender
47 | System.String
48 |
49 |
50 | Contact
51 | System.String
52 |
53 |
54 | Description
55 | System.String
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 | 1.02083in
69 |
70 |
71 | 1in
72 |
73 |
74 | 1.02083in
75 |
76 |
77 | 1.02083in
78 |
79 |
80 | 1in
81 |
82 |
83 | 1in
84 |
85 |
86 | 1in
87 |
88 |
89 | 1in
90 |
91 |
92 |
93 |
94 | 0.25in
95 |
96 |
97 |
98 |
99 | true
100 | true
101 |
102 |
103 |
104 |
105 | Location
106 |
107 |
108 |
109 |
110 |
111 |
112 | Textbox1
113 |
117 |
118 | 2pt
119 | 2pt
120 | 2pt
121 | 2pt
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 | true
130 | true
131 |
132 |
133 |
134 |
135 | Rooms
136 |
139 |
140 |
141 |
142 |
143 |
144 | Textbox8
145 |
149 |
150 | 2pt
151 | 2pt
152 | 2pt
153 | 2pt
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 | true
162 | true
163 |
164 |
165 |
166 |
167 | City
168 |
169 |
170 |
171 |
172 |
173 |
174 | Textbox3
175 |
179 |
180 | 2pt
181 | 2pt
182 | 2pt
183 | 2pt
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 | true
192 | true
193 |
194 |
195 |
196 |
197 | Demand
198 |
199 |
200 |
201 |
202 |
203 |
204 | Textbox5
205 |
209 |
210 | 2pt
211 | 2pt
212 | 2pt
213 | 2pt
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 | true
222 | true
223 |
224 |
225 |
226 |
227 | Description
228 |
231 |
232 |
233 |
234 |
235 |
236 | Textbox10
237 |
241 |
242 | 2pt
243 | 2pt
244 | 2pt
245 | 2pt
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 | true
254 | true
255 |
256 |
257 |
258 |
259 | Name
260 |
263 |
264 |
265 |
266 |
267 |
268 | Textbox12
269 |
273 |
274 | 2pt
275 | 2pt
276 | 2pt
277 | 2pt
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 | true
286 | true
287 |
288 |
289 |
290 |
291 | Contact
292 |
295 |
296 |
297 |
298 |
299 |
300 | Textbox14
301 |
305 |
306 | 2pt
307 | 2pt
308 | 2pt
309 | 2pt
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 | true
318 | true
319 |
320 |
321 |
322 |
323 | Gender
324 |
327 |
328 |
329 |
330 |
331 |
332 | Textbox16
333 |
337 |
338 | 2pt
339 | 2pt
340 | 2pt
341 | 2pt
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 | 0.25in
350 |
351 |
352 |
353 |
354 | true
355 | true
356 |
357 |
358 |
359 |
360 | =Fields!Location.Value
361 |
362 |
363 |
364 |
365 |
366 |
367 | Location
368 |
372 |
373 | 2pt
374 | 2pt
375 | 2pt
376 | 2pt
377 |
378 |
379 |
380 |
381 |
382 |
383 |
384 | true
385 | true
386 |
387 |
388 |
389 |
390 | =Fields!Rooms.Value
391 |
394 |
395 |
396 |
397 |
398 |
399 | Rooms
400 |
404 |
405 | 2pt
406 | 2pt
407 | 2pt
408 | 2pt
409 |
410 |
411 |
412 |
413 |
414 |
415 |
416 | true
417 | true
418 |
419 |
420 |
421 |
422 | =Fields!City.Value
423 |
424 |
425 |
426 |
427 |
428 |
429 | City
430 |
434 |
435 | 2pt
436 | 2pt
437 | 2pt
438 | 2pt
439 |
440 |
441 |
442 |
443 |
444 |
445 |
446 | true
447 | true
448 |
449 |
450 |
451 |
452 | =Fields!Demand.Value
453 |
454 |
455 |
456 |
457 |
458 |
459 | Demand
460 |
464 |
465 | 2pt
466 | 2pt
467 | 2pt
468 | 2pt
469 |
470 |
471 |
472 |
473 |
474 |
475 |
476 | true
477 | true
478 |
479 |
480 |
481 |
482 | =Fields!Description.Value
483 |
486 |
487 |
488 |
489 |
490 |
491 | Description
492 |
496 |
497 | 2pt
498 | 2pt
499 | 2pt
500 | 2pt
501 |
502 |
503 |
504 |
505 |
506 |
507 |
508 | true
509 | true
510 |
511 |
512 |
513 |
514 | =Fields!Name.Value
515 |
518 |
519 |
520 |
521 |
522 |
523 | Name
524 |
528 |
529 | 2pt
530 | 2pt
531 | 2pt
532 | 2pt
533 |
534 |
535 |
536 |
537 |
538 |
539 |
540 | true
541 | true
542 |
543 |
544 |
545 |
546 | =Fields!Contact.Value
547 |
550 |
551 |
552 |
553 |
554 |
555 | Contact
556 |
560 |
561 | 2pt
562 | 2pt
563 | 2pt
564 | 2pt
565 |
566 |
567 |
568 |
569 |
570 |
571 |
572 | true
573 | true
574 |
575 |
576 |
577 |
578 | =Fields!Gender.Value
579 |
582 |
583 |
584 |
585 |
586 |
587 | Gender
588 |
592 |
593 | 2pt
594 | 2pt
595 | 2pt
596 | 2pt
597 |
598 |
599 |
600 |
601 |
602 |
603 |
604 |
605 |
606 |
607 |
608 |
609 |
610 |
611 |
612 |
613 |
614 |
615 |
616 |
617 |
618 |
619 |
620 | After
621 |
622 |
623 |
624 |
625 |
626 |
627 | DataSet1
628 | 0.35986in
629 | 0.16542in
630 | 0.5in
631 | 8.0625in
632 |
635 |
636 |
637 |
638 |
639 | true
640 | true
641 |
642 |
643 |
644 |
645 | My first Report
646 |
647 |
648 |
649 |
650 |
651 |
652 | Textbox7
653 | 0.29042in
654 | 6.5in
655 | 1
656 |
659 |
660 | 2pt
661 | 2pt
662 | 2pt
663 | 2pt
664 |
665 |
666 |
667 | 2in
668 |
669 |
670 | 8.22792in
671 |
672 | 1in
673 | 1in
674 | 1in
675 | 1in
676 |
677 |
678 |
679 |
680 |
681 |
682 | 4
683 | 2
684 |
685 |
686 | Inch
687 | b97adde8-6c12-4583-a761-4e9c5c8b2f13
688 |
--------------------------------------------------------------------------------
/FirstTestReport/FirstTestReport/Report1.rdl.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/muhammadfaraz6640/Database-Management-System/51e5c5104933389f884abf2c9463d4b1ed31bd73/FirstTestReport/FirstTestReport/Report1.rdl.data
--------------------------------------------------------------------------------
/FirstTestReport/FirstTestReport/bin/Debug/RealEstate.rds:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | SQL
5 |
6 |
7 | e215e435-42b6-49b1-9bf6-62efe1c0effb
8 |
--------------------------------------------------------------------------------
/FirstTestReport/FirstTestReport/bin/Debug/Report1.rdl:
--------------------------------------------------------------------------------
1 |
2 |
3 | Segoe UI
4 | 0
5 |
6 |
7 |
8 | SQL
9 | Data Source=MUHAMMADFARAZAN\SQLEXPRESS;Initial Catalog=RealEstateManagementSystem
10 | true
11 |
12 | Integrated
13 | 727b24a3-5e57-4733-8192-a502c624c1bb
14 |
15 |
16 |
17 |
18 |
19 | DataSource1
20 | SELECT Property.City, Property.Location, Property.Rooms, Property.Demand, Seller.Name, Seller.Gender, Seller.Contact, Property.Description
21 | FROM Property INNER JOIN
22 | Seller ON Property.Sid = Seller.Sid
23 |
24 |
25 |
26 | City
27 | System.String
28 |
29 |
30 | Location
31 | System.String
32 |
33 |
34 | Rooms
35 | System.String
36 |
37 |
38 | Demand
39 | System.String
40 |
41 |
42 | Name
43 | System.String
44 |
45 |
46 | Gender
47 | System.String
48 |
49 |
50 | Contact
51 | System.String
52 |
53 |
54 | Description
55 | System.String
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 | 1.02083in
69 |
70 |
71 | 1in
72 |
73 |
74 | 1.02083in
75 |
76 |
77 | 1.02083in
78 |
79 |
80 | 1in
81 |
82 |
83 | 1in
84 |
85 |
86 | 1in
87 |
88 |
89 | 1in
90 |
91 |
92 |
93 |
94 | 0.25in
95 |
96 |
97 |
98 |
99 | true
100 | true
101 |
102 |
103 |
104 |
105 | Location
106 |
107 |
108 |
109 |
110 |
111 |
112 | Textbox1
113 |
117 |
118 | 2pt
119 | 2pt
120 | 2pt
121 | 2pt
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 | true
130 | true
131 |
132 |
133 |
134 |
135 | Rooms
136 |
139 |
140 |
141 |
142 |
143 |
144 | Textbox8
145 |
149 |
150 | 2pt
151 | 2pt
152 | 2pt
153 | 2pt
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 | true
162 | true
163 |
164 |
165 |
166 |
167 | City
168 |
169 |
170 |
171 |
172 |
173 |
174 | Textbox3
175 |
179 |
180 | 2pt
181 | 2pt
182 | 2pt
183 | 2pt
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 | true
192 | true
193 |
194 |
195 |
196 |
197 | Demand
198 |
199 |
200 |
201 |
202 |
203 |
204 | Textbox5
205 |
209 |
210 | 2pt
211 | 2pt
212 | 2pt
213 | 2pt
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 | true
222 | true
223 |
224 |
225 |
226 |
227 | Description
228 |
231 |
232 |
233 |
234 |
235 |
236 | Textbox10
237 |
241 |
242 | 2pt
243 | 2pt
244 | 2pt
245 | 2pt
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 | true
254 | true
255 |
256 |
257 |
258 |
259 | Name
260 |
263 |
264 |
265 |
266 |
267 |
268 | Textbox12
269 |
273 |
274 | 2pt
275 | 2pt
276 | 2pt
277 | 2pt
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 | true
286 | true
287 |
288 |
289 |
290 |
291 | Contact
292 |
295 |
296 |
297 |
298 |
299 |
300 | Textbox14
301 |
305 |
306 | 2pt
307 | 2pt
308 | 2pt
309 | 2pt
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 | true
318 | true
319 |
320 |
321 |
322 |
323 | Gender
324 |
327 |
328 |
329 |
330 |
331 |
332 | Textbox16
333 |
337 |
338 | 2pt
339 | 2pt
340 | 2pt
341 | 2pt
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 | 0.25in
350 |
351 |
352 |
353 |
354 | true
355 | true
356 |
357 |
358 |
359 |
360 | =Fields!Location.Value
361 |
362 |
363 |
364 |
365 |
366 |
367 | Location
368 |
372 |
373 | 2pt
374 | 2pt
375 | 2pt
376 | 2pt
377 |
378 |
379 |
380 |
381 |
382 |
383 |
384 | true
385 | true
386 |
387 |
388 |
389 |
390 | =Fields!Rooms.Value
391 |
394 |
395 |
396 |
397 |
398 |
399 | Rooms
400 |
404 |
405 | 2pt
406 | 2pt
407 | 2pt
408 | 2pt
409 |
410 |
411 |
412 |
413 |
414 |
415 |
416 | true
417 | true
418 |
419 |
420 |
421 |
422 | =Fields!City.Value
423 |
424 |
425 |
426 |
427 |
428 |
429 | City
430 |
434 |
435 | 2pt
436 | 2pt
437 | 2pt
438 | 2pt
439 |
440 |
441 |
442 |
443 |
444 |
445 |
446 | true
447 | true
448 |
449 |
450 |
451 |
452 | =Fields!Demand.Value
453 |
454 |
455 |
456 |
457 |
458 |
459 | Demand
460 |
464 |
465 | 2pt
466 | 2pt
467 | 2pt
468 | 2pt
469 |
470 |
471 |
472 |
473 |
474 |
475 |
476 | true
477 | true
478 |
479 |
480 |
481 |
482 | =Fields!Description.Value
483 |
486 |
487 |
488 |
489 |
490 |
491 | Description
492 |
496 |
497 | 2pt
498 | 2pt
499 | 2pt
500 | 2pt
501 |
502 |
503 |
504 |
505 |
506 |
507 |
508 | true
509 | true
510 |
511 |
512 |
513 |
514 | =Fields!Name.Value
515 |
518 |
519 |
520 |
521 |
522 |
523 | Name
524 |
528 |
529 | 2pt
530 | 2pt
531 | 2pt
532 | 2pt
533 |
534 |
535 |
536 |
537 |
538 |
539 |
540 | true
541 | true
542 |
543 |
544 |
545 |
546 | =Fields!Contact.Value
547 |
550 |
551 |
552 |
553 |
554 |
555 | Contact
556 |
560 |
561 | 2pt
562 | 2pt
563 | 2pt
564 | 2pt
565 |
566 |
567 |
568 |
569 |
570 |
571 |
572 | true
573 | true
574 |
575 |
576 |
577 |
578 | =Fields!Gender.Value
579 |
582 |
583 |
584 |
585 |
586 |
587 | Gender
588 |
592 |
593 | 2pt
594 | 2pt
595 | 2pt
596 | 2pt
597 |
598 |
599 |
600 |
601 |
602 |
603 |
604 |
605 |
606 |
607 |
608 |
609 |
610 |
611 |
612 |
613 |
614 |
615 |
616 |
617 |
618 |
619 |
620 | After
621 |
622 |
623 |
624 |
625 |
626 |
627 | DataSet1
628 | 0.35986in
629 | 0.16542in
630 | 0.5in
631 | 8.0625in
632 |
635 |
636 |
637 |
638 |
639 | true
640 | true
641 |
642 |
643 |
644 |
645 | My first Report
646 |
647 |
648 |
649 |
650 |
651 |
652 | Textbox7
653 | 0.29042in
654 | 6.5in
655 | 1
656 |
659 |
660 | 2pt
661 | 2pt
662 | 2pt
663 | 2pt
664 |
665 |
666 |
667 | 2in
668 |
669 |
670 | 8.22792in
671 |
672 | 1in
673 | 1in
674 | 1in
675 | 1in
676 |
677 |
678 |
679 |
680 |
681 |
682 | 4
683 | 2
684 |
685 |
686 | Inch
687 | b97adde8-6c12-4583-a761-4e9c5c8b2f13
688 |
--------------------------------------------------------------------------------
/FirstTestReport/FirstTestReport/bin/Debug/build.obj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/muhammadfaraz6640/Database-Management-System/51e5c5104933389f884abf2c9463d4b1ed31bd73/FirstTestReport/FirstTestReport/bin/Debug/build.obj
--------------------------------------------------------------------------------
/Labs/DBMS LAB2.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/muhammadfaraz6640/Database-Management-System/51e5c5104933389f884abf2c9463d4b1ed31bd73/Labs/DBMS LAB2.docx
--------------------------------------------------------------------------------
/Labs/DBMS LAB3.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/muhammadfaraz6640/Database-Management-System/51e5c5104933389f884abf2c9463d4b1ed31bd73/Labs/DBMS LAB3.docx
--------------------------------------------------------------------------------
/Labs/DBMS LAB7.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/muhammadfaraz6640/Database-Management-System/51e5c5104933389f884abf2c9463d4b1ed31bd73/Labs/DBMS LAB7.docx
--------------------------------------------------------------------------------
/Labs/data_definition.sql:
--------------------------------------------------------------------------------
1 | select * from dept40
2 |
3 | create table dept40(
4 | deptID int primary key,
5 | Dname nvarchar(50),
6 | Location nvarchar(max)
7 | )
8 |
9 |
10 | insert into dept40 select * from dept
11 |
12 | create table EMPA(
13 | empno int primary key,
14 | firstName nvarchar(20),
15 | lastName nvarchar(20),
16 | deptID int foreign key references dept40
17 | )
18 |
19 | alter table empa alter column lastName nvarchar(max)
20 |
21 | SELECT EMPA
22 | FROM labs.INFORMATION_SCHEMA.empid
23 |
24 | SELECT TABLE_NAME, TABLE_TYPE
25 | FROM labs.INFORMATION_SCHEMA.TABLES
26 | ORDER BY TABLE_NAME
27 |
28 | select EMPNO, ENAME, SAL, DEPTNO into EMP2 from emp
29 |
30 | select * from emp3
31 |
32 |
33 | drop table empa
34 |
35 |
36 | EXEC sp_rename 'emp2', 'emp3';
37 |
38 | EXEC sp_addextendedproperty
39 | @name = N'MS_Description', @value = 'This is my comment on emp3 table',
40 | @level0type = N'Schema', @level0name = 'dbo',
41 | @level1type = N'Table', @level1name = 'emp3',
42 | @level2type = N'Column', @level2name = 'ename'
43 |
44 |
45 | select *
46 | from INFORMATION_SCHEMA.COLUMNS
47 | where TABLE_NAME='emp3'
48 |
49 | SELECT
50 | *
51 | FROM
52 | sys.extended_properties
53 | WHERE
54 | major_id = OBJECT_ID('emp3')
55 | AND
56 | minor_id = COLUMNPROPERTY(major_id, 'ename', 'ColumnId')
57 |
58 | alter table emp3 drop column ename
59 |
60 |
61 | ALTER TABLE emp3 SET UNUSED ( deptno );
62 |
63 | ALTER TABLE emp3 DROP UNUSED deptno;
64 |
65 |
66 | comment on table emp3 is 'hello'
67 |
68 |
69 |
--------------------------------------------------------------------------------
/Labs/lab1.sql:
--------------------------------------------------------------------------------
1 | create database DBMS
2 |
3 | create table Dept(
4 | DEPTNO int primary key,
5 | DNAME nvarchar(50),
6 | LOC nvarchar(50),
7 | )
8 |
9 | create table EMP(
10 | EMPNO int primary key identity,
11 | ENAME nvarchar(50),
12 | JOB nvarchar(50),
13 | MGR nvarchar(50),
14 | HIREDATE nvarchar(50),
15 | SAL nvarchar(50),
16 | COMM nvarchar(50),
17 | DEPTNO int
18 | )
19 |
20 | create table SALGRADE(
21 | GRA nvarchar(50),
22 | LOWEST_SAL nvarchar(50),
23 | HIGHEST_SAL nvarchar(50),
24 | )
25 |
26 | insert into Dept values(10,'Accounting','NewYork')
27 | insert into Dept values(20,'Research','Dallas');
28 | insert into Dept values(30,'Sales','Chicago')
29 | insert into Dept values(40,'Opeartions','Boston')
30 |
31 | select * from Dept
32 |
33 | insert into SALGRADE values('A',1000,2999)
34 | insert into SALGRADE values('B',2000,5999)
35 | insert into SALGRADE values('C',4000,8999)
36 | insert into SALGRADE values('D',5000,9999)
37 | insert into SALGRADE values('E',7000,12999)
38 |
39 | select * from SALGRADE
40 |
41 | insert into EMP values('smith','clerk','7902','17-DEC-80',2000,null,20)
42 | insert into EMP values('john','Assistant manager','7906','13-DEC-81',50000,300,10)
43 |
44 | select * from EMP
45 |
46 | SELECT ename, job, sal AS Salary FROM emp; /*true*/
47 | SELECT * FROM salgrades; /*false*/
48 |
49 | SELECT empno, ename, sal * 12 as "ANNUAL SALARY" FROM emp;
50 |
51 | select * from Dept
52 |
53 | select *
54 | from INFORMATION_SCHEMA.COLUMNS
55 | where TABLE_NAME='Emp'
56 |
57 |
58 | select empno, ename, job , hiredate from EMP
59 |
60 | select distinct job from EMP
61 |
62 | headings Emp#. Employee, Job and Hire Date
63 | select empno as Emp#, ename as Employee, job "Job" , hiredate as "Hire Date" from EMP
64 |
65 |
66 | select ENAME+','+' '+JOB as "Employee And Title" from EMP;
67 |
68 | select ENAME+','+JOB+','+MGR+','+HIREDATE+','+SAL+','+COMM+','+DEPTNO as THE_OUTPUT from EMP;
--------------------------------------------------------------------------------
/Labs/lab4.sql:
--------------------------------------------------------------------------------
1 | select * from salgrade
2 | select * from emp where DEPTNO = 30
3 | select * from dept
4 |
5 | select gra from salgrade where
6 |
7 | select e.ename , d.deptno , d.dname from emp e , dept d where e.DEPTNO = d.DEPTNO
8 |
9 | select distinct e.job , d.loc from emp e inner join dept d where d.DEPTNO = e.deptno and d.DEPTNO = 30
10 |
11 | select e.ename , d.dname , d.loc from emp e , dept d where d.DEPTNO = e.DEPTNO and e.COMM is not null
12 |
13 | select e.ename , d.dname , d.loc from emp e , dept d where e.COMM is not null
14 | SELECT *
15 | FROM Test
16 | WHERE col1
17 | LIKE '%[abcdefghijklmnopqrstuvwxyz]%'
18 | collate Latin1_General_CS_AS
19 |
20 | select e.ename , d.dname from emp e, dept d where e.ENAME LIKE '%[abcdefghijklmnopqrstuvwxyz]%'
21 | collate Latin1_General_CS_AS
22 |
23 | select e.ename , e.job , d.dname , d.deptno from emp e , dept d where d.DEPTNO = e.DEPTNO and d.loc = 'CHICAGO'
24 |
25 | select ename as MGR# , empno as EMP# from emp where job != 'MANAGER' order by ename
26 |
27 | select e.ename , d.deptno from emp e , dept d where d.DEPTNO = ( select deptno from emp where ename = 'SMITH') /* name chosen smith*/
28 |
29 | select *
30 | from INFORMATION_SCHEMA.COLUMNS
31 | where TABLE_NAME='salgrade'
32 |
33 | select e.ename , e.job , e.sal , d.dname , s.gra from emp e, dept d, salgrade s where d.DEPTNO = e.DEPTNO and e.sal BETWEEN s.lowest_sal AND s.highest_sal
34 |
35 | select ename , hiredate from emp where HIREDATE > (select hiredate from emp where ename = 'SMITH') /*davies doesnot exist so i write smith*/
36 |
37 | select ename , hiredate from emp where HIREDATE < (select hiredate from emp where job = 'MANAGER')
38 |
39 |
40 |
--------------------------------------------------------------------------------
/Labs/lab6.sql:
--------------------------------------------------------------------------------
1 | alter table emp alter column sal int
2 | select * from emp
3 |
4 | select * from dept
5 |
6 |
7 | select empno , ename from emp where sal > (select AVG(Sal) from emp)
8 |
9 |
10 | select empno , ename from emp where ename = any (select ename from emp where ename like '%au%')
11 |
12 |
13 | select ename , deptno , job from emp where DEPTNO = 1700
14 |
15 | select ename , sal from emp where deptno = (select DEPTNO from emp where ename = 'smith')
16 |
17 |
18 | select deptno , empno as JobID , ename from emp where DEPTNO = 10 /*10 is executive dept */
19 |
20 |
21 | select empno , ename , sal from emp where sal > (select AVG(Sal) from emp) and ename = any (select ename from emp where ename like '%au%')
--------------------------------------------------------------------------------
/Like SQL.sql:
--------------------------------------------------------------------------------
1 | select * from Patient
2 |
3 | select Patient_FirstName,Patient_Address from Patient where Patient_Address like '%99%'
4 |
5 |
--------------------------------------------------------------------------------
/Nested Queries.sql:
--------------------------------------------------------------------------------
1 | select ADate,ATime,Examination_RoomNo from Appointments
2 | where Patient_id = ( select Patient_id from Patient where Patient_gender = 'Male' AND LocalDoctor_id = 1 )
3 |
4 |
5 | select FirstName,LastName from staff where Qid =
6 | (select Qid from Qualification where TypeQualificaion = 'Nursing') AND Expid =
7 | (select Expid from Experience where ExpOrganization = 'Ned University')
--------------------------------------------------------------------------------
/No Action Refrential integrity constraints.sql:
--------------------------------------------------------------------------------
1 | create database company
2 |
3 | create table employee(
4 | emp_id int primary key identity not null,
5 | emp_name nvarchar(50)
6 | );
7 |
8 | create table branch(
9 | bid int primary key identity not null,
10 | BName nvarchar(50)
11 | );
12 | alter table employee drop column bid
13 | alter table employee add bid int foreign key REFERENCES branch(bid) on delete no action /*it deny the deletion*/
14 | drop table employee
15 |
16 | select * from employee
17 | select * from branch
18 |
19 | insert into branch values('Nazimabad')
20 |
21 | insert into employee values('faraz',2)
22 |
23 | delete from branch where bid = 2 /*it refuses*/
24 |
--------------------------------------------------------------------------------
/Numeric data Types.sql:
--------------------------------------------------------------------------------
1 | create table DataTypeNumeric(
2 | integers int, /*-2,147,483,648 to 2,147,483,647*/
3 | big_int bigint, /*-9,223,372,036, 854,775,808 9,223,372,036, 854,775,807*/
4 | small_int smallint, /*32,768 32,767*/
5 | binarydigit bit, /* 0 or 1*/
6 | tiny_int tinyint, /* 0 to 255*/
7 | float_num float, /* bigger than real*/
8 | real_num real
9 | );
10 |
11 | alter table DataTypeNumeric add NTN_id int primary key identity not null
12 | select * from DataTypeNumeric
13 | insert into DataTypeNumeric values(2500,-748998329,7865,1,259,19.01E23,12.78) /* terminated becuase tiny int exceeded*/
14 |
15 | insert into DataTypeNumeric values(2500,-748998329,7865,4,123,19.01E23,12.78) /*not terminated whether i wrote bit with 4 it takes 1*/
16 |
17 | insert into DataTypeNumeric values(2500,-748998329,7865,1,100,19.01E309,12.78) /* terminated becuase float limit power is 308 exceeded*/
18 |
19 | insert into DataTypeNumeric values(-18787827387283782378232,-748998329,7865,1,100,19.01E23,12.78) /* terminated becuase int exceeded*/
--------------------------------------------------------------------------------
/PerdaySalary.sql:
--------------------------------------------------------------------------------
1 | select CurrentSalary/30 from staff /*perday salary*/
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Database-Management-System
2 | Complete Queries , Commands , Erd Models , Relationships Between Tables , Views , StoredProcedures etc using MS SQL Server
3 |
--------------------------------------------------------------------------------
/Set Null Refrential Integrity constraints.sql:
--------------------------------------------------------------------------------
1 | create database company
2 |
3 | create table employee(
4 | emp_id int primary key identity not null,
5 | emp_name nvarchar(50)
6 | );
7 |
8 | create table branch(
9 | bid int primary key identity not null,
10 | BName nvarchar(50)
11 | );
12 | alter table employee drop column bid
13 | alter table employee add bid int foreign key REFERENCES branch(bid) on delete set null /*set null means deleteing parent table row can result in set null in matching row in child table*/
14 | drop table employee
15 |
16 | select * from employee
17 |
18 | insert into branch values('Nazimabad')
19 |
20 | insert into employee values('faraz',1)
21 |
22 | delete from branch where bid = 1 /*now its set to null in child table*/
23 |
24 |
--------------------------------------------------------------------------------
/String Data Types.sql:
--------------------------------------------------------------------------------
1 | create table StringDataTypes(
2 | characters char(10), /* it takes fixed length storage of 10 bits in ram either you enter only 5 characters memory consumes more and extra */
3 | char_varchar nvarchar(100), /* it takes variable length storage of 100 characters with maximium of 800 characters it takes memory that you enters */
4 | char_text text, /*stores data upto 2GB*/
5 | char_max nvarchar(max), /*no limit with variable length stroage*/
6 | );
7 |
--------------------------------------------------------------------------------
/TableCreation.sql:
--------------------------------------------------------------------------------
1 | create table Admin(
2 | Aid int primary key identity not null,
3 | AName nvarchar(50),
4 | AEmail nvarchar(50),
5 | APassword nvarchar(50),
6 | AStatus nvarchar(50),
7 | role nvarchar(50) /* table for Admin*/
8 | )
9 |
10 | create table Login(
11 | Lid int primary key identity not null,
12 | Name nvarchar(50),
13 | Email nvarchar(50),
14 | Password nvarchar(50),
15 | role nvarchar(50) /* table for Login*/
16 | )
17 |
18 |
19 | create table Categories(
20 | Cid int primary key identity not null,
21 | CatName nvarchar(50),
22 |
23 | /* table for Categories*/
24 | )
25 | create table Product(
26 | Pid int primary key identity not null,
27 | Cid int,
28 | PName nvarchar(50),
29 | Barcode nvarchar(max),
30 | Expiry nvarchar(50),
31 | /* table for Product*/
32 | )
33 | create table PurchaseInvoice(
34 | PIid int primary key identity not null,
35 | Pid int,
36 | Qty nvarchar(50),
37 | PerUnitPrice nvarchar(50),
38 | Total nvarchar(max),
39 | /* table for PurchaseInvoice*/
40 | )
41 | create table Supplier(
42 | Sid int primary key identity not null,
43 |
44 | SName nvarchar(50),
45 | SContact nvarchar(50),
46 | SAddress nvarchar(max),
47 | SNtn nvarchar(50),
48 | Status nvarchar(50),
49 | /* table for Supplier*/
50 | )
51 | create table Workers(
52 | Wid int primary key identity not null,
53 | WName nvarchar(50),
54 | WContact nvarchar(50),
55 | WAddress nvarchar(max),
56 | WEmail nvarchar(50),
57 | WDesignation nvarchar(max),
58 | WPassword nvarchar(50),
59 | /* table for Workers*/
60 | )
61 | create table ProductPricing(
62 | PPid int primary key identity not null,
63 | PIid int,
64 | ProfitPercent nvarchar(50),
65 | DiscountPercent nvarchar(50),
66 | FinalPrice nvarchar(max),
67 | /* table for ProductPricing*/
68 | )
69 | create table Sales(
70 | SLid int primary key identity not null,
71 | PIid int,
72 | PQty nvarchar(50),
73 | GrossTotal nvarchar(50),
74 | TotalPriceEach nvarchar(50),
75 | DiscountPrice nvarchar(50)
76 | /* table for Sales*/
77 | )
78 | create table Bill(
79 | Bid int primary key identity not null,
80 | SLid int,
81 | /* table for Bill*/
82 | )
83 | create table History(
84 | Hid int primary key identity not null,
85 | Wid int,
86 | TimeLogin nvarchar(50),
87 | TimeLogout nvarchar(50)
88 | /* table for History*/
89 | )
90 |
--------------------------------------------------------------------------------
/erd.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/muhammadfaraz6640/Database-Management-System/51e5c5104933389f884abf2c9463d4b1ed31bd73/erd.PNG
--------------------------------------------------------------------------------
/refrential integrity cascade constraints.sql:
--------------------------------------------------------------------------------
1 | create database company
2 |
3 | create table employee(
4 | emp_id nt primary key identity not null,
5 | emp_name nvarchar(50)
6 | );
7 |
8 | create table branch(
9 | bid int primary key identity not null,
10 | BName nvarchar(50)
11 | );
12 |
13 | alter table employee add bid int foreign key REFERENCES branch(bid) on delete cascade /*cascade means deleteing parent table row can result in deleting matching row in child table*/
14 |
15 | select * from employee,branch
16 |
17 | insert into branch values('Nazimabad')
18 |
19 | insert into employee values('faraz',1)
20 |
21 | delete from employee where emp_id =1 /*now its deleted the child table matching row too*/
--------------------------------------------------------------------------------
/stored Procedures.sql:
--------------------------------------------------------------------------------
1 | Create PROCEDURE InsertProductProcedure
2 | (
3 | @name nvarchar(50),
4 | @description nvarchar(max),
5 | @price int,
6 | @Qty int,
7 | @image nvarchar(max),
8 | @category int
9 | )
10 | AS
11 | BEGIN
12 | insert into ProductView(name,description,price,quantity,image,category) values (@name,@description,@price,@Qty,@image,@category)
13 | END
14 |
15 | select * from Category
--------------------------------------------------------------------------------