20 | | ==== 3. Motorcycles ==== |
21 | | '''Id''' – SERIAL (Primary Key) // |
22 | | '''!ClientId''' – INT (Mandatory attribute, Foreign Key to Clients.Id with ON DELETE CASCADE) // |
23 | | '''!Model''' – VARCHAR(50) (Mandatory attribute) // |
24 | | '''Year''' – INT // |
25 | | '''!ChassisNumber''' – VARCHAR(50) (Unique) // |
26 | | '''Registration''' – VARCHAR(20) // |
27 | | '''Kilometers''' – INT // |
| 20 | ==== 3. Motorcycle ==== |
| 21 | '''Id''' – SERIAL (Primary Key)\\ |
| 22 | '''!ClientId''' – INT (Mandatory attribute, Foreign Key to Client.Id)\\ |
| 23 | '''Model''' – VARCHAR(50) (Mandatory attribute)\\ |
| 24 | '''Year''' – INT\\ |
| 25 | '''!ChassisNumber''' – VARCHAR(50) (Unique)\\ |
| 26 | '''Registration''' – VARCHAR(20)\\ |
| 27 | '''Kilometers''' – INT\\ |
29 | | ==== 4. ServiceItems ==== |
30 | | '''Id''' – SERIAL (Primary Key) // |
31 | | '''!Description''' – TEXT (Mandatory attribute) // |
32 | | '''!MeasurementUnit''' – VARCHAR(20) (Mandatory attribute) // |
33 | | '''!PricePerUnit''' – DECIMAL(10,2) (Mandatory attribute) // |
34 | | '''Tax''' – DECIMAL(5,2) (Mandatory attribute) // |
| 29 | ==== 4. !ServiceItem ==== |
| 30 | '''Id''' – SERIAL (Primary Key)\\ |
| 31 | '''Description''' – TEXT (Mandatory attribute)\\ |
| 32 | '''!MeasurementUnit''' – VARCHAR(20) (Mandatory attribute)\\ |
| 33 | '''!PricePerUnit''' – DECIMAL(10,2) (Mandatory attribute)\\ |
| 34 | '''Tax''' – DECIMAL(5,2) (Mandatory attribute)\\ |
36 | | ==== 5. Services ==== |
37 | | '''Id''' – SERIAL (Primary Key) // |
38 | | '''!MotorcycleId''' – INT (Mandatory attribute, Foreign Key to Motorcycles.Id with ON DELETE CASCADE) // |
39 | | '''!DateOfService''' – DATE (Mandatory attribute) // |
40 | | '''!LaborCost''' – DECIMAL(10,2) (Mandatory attribute) // |
41 | | '''!TotalPrice''' – DECIMAL(10,2) (Mandatory attribute; calculated manually by the application) // |
| 36 | ==== 5. Service ==== |
| 37 | '''Id''' – SERIAL (Primary Key)\\ |
| 38 | '''!MotorcycleId''' – INT (Mandatory attribute, Foreign Key to Motorcycle.Id)\\ |
| 39 | '''!DateOfService''' – DATE (Mandatory attribute)\\ |
| 40 | '''!LaborCost''' – DECIMAL(10,2) (Mandatory attribute)\\ |
| 41 | '''!TotalPrice''' – DECIMAL(10,2) (Generated, Mandatory attribute)\\ |
43 | | ==== 6. ServiceAssignments ==== |
44 | | '''!ServiceId''' – INT (Foreign Key to Services.Id with ON DELETE CASCADE) // |
45 | | '''MechanicEMBG''' – VARCHAR(13) (Foreign Key to Mechanics.EMBG with ON DELETE CASCADE) // |
46 | | '''!ServiceItemId''' – INT (Foreign Key to ServiceItems.Id with ON DELETE CASCADE) // |
47 | | '''!UnitsUsed''' – DECIMAL(10,2) (Mandatory attribute) // |
48 | | '''Composite Primary Key''': (ServiceId, MechanicEMBG, ServiceItemId) // |
| 43 | ==== 6. !ServiceAssignment (Junction Table) ==== |
| 44 | '''!ServiceId''' – INT (Foreign Key to Service.Id)\\ |
| 45 | '''MechanicEMBG''' – VARCHAR(13) (Foreign Key to Mechanic.EMBG)\\ |
| 46 | '''!ServiceItemId''' – INT (Foreign Key to !ServiceItem.Id)\\ |
| 47 | '''!UnitsUsed''' – DECIMAL(10,2) (Mandatory attribute)\\ |
| 48 | '''Composite Primary Key''': (!ServiceId, MechanicEMBG, !ServiceItemId)\\ |
50 | | ==== 7. ServiceInvoices ==== |
51 | | '''Id''' – SERIAL (Primary Key) // |
52 | | '''!ServiceId''' – INT (Unique, Mandatory attribute, Foreign Key to Services.Id with ON DELETE CASCADE) // |
53 | | '''!IssueDate''' – TIMESTAMP (Mandatory attribute, defaults to NOW()) // |
54 | | '''!ImagePath''' – TEXT (Mandatory attribute) // |
| 50 | ==== 7. !ServiceInvoice ==== |
| 51 | '''Id''' – SERIAL (Primary Key)\\ |
| 52 | '''!ServiceId''' – INT (Unique, Mandatory attribute, Foreign Key to Service.Id)\\ |
| 53 | '''!IssueDate''' – TIMESTAMP (Mandatory attribute)\\ |
| 54 | '''!ImagePath''' – TEXT (Mandatory attribute)\\ |
56 | | ==== 8. FiscalBills ==== |
57 | | '''Id''' – SERIAL (Primary Key) // |
58 | | '''!ServiceInvoiceId''' – INT (Unique, Mandatory attribute, Foreign Key to ServiceInvoices.Id with ON DELETE CASCADE) // |
59 | | '''!IssueDateTime''' – TIMESTAMP (Mandatory attribute, defaults to NOW()) // |
60 | | '''Description''' – TEXT // |
61 | | '''DDV''' – DECIMAL(5,2) (Mandatory attribute) // |
62 | | '''EDB''' – VARCHAR(15) (Mandatory attribute) // |
| 56 | ==== 8. !FiscalBill ==== |
| 57 | '''Id''' – SERIAL (Primary Key)\\ |
| 58 | '''!ServiceInvoiceId''' – INT (Unique, Mandatory attribute, Foreign Key to !ServiceInvoice.Id)\\ |
| 59 | '''!IssueDateTime''' – TIMESTAMP (Mandatory attribute)\\ |
| 60 | '''Description''' – TEXT\\ |
| 61 | '''DDV''' – DECIMAL(5,2) (Mandatory attribute, VAT)\\ |
| 62 | '''EDB''' – VARCHAR(15) (Mandatory attribute, Tax ID)\\ |
| 63 | |