16 | | === 2. Motorcycle |
17 | | * registration - varchar (Primary key) |
18 | | * chassis_number - varchar (Mandatory attribute) |
19 | | * year - date (Mandatory attribute) |
20 | | * model - varchar (Mandatory attribute) |
| 22 | = 3. Service = |
| 23 | Service ID – serial (Primary Key) |
| 24 | Client telephone number – varchar (Foreign Key to Client) |
| 25 | Motorcycle registration – varchar (Foreign Key to Motorcycle) |
| 26 | Service date – date (Mandatory attribute) |
| 27 | Total price – numeric (Mandatory attribute) |
27 | | === 4. Service |
28 | | * service_id - serial (Primary key) |
29 | | * client_id - varchar (Foreign key referencing Client.telephone_number, Mandatory attribute) |
30 | | * motorcycle_registration - varchar (Foreign key referencing Motorcycle.registration, Mandatory attribute) |
31 | | * service_date - date (Mandatory attribute) |
32 | | * total_price - numeric (Mandatory attribute) |
| 34 | = 5. Service Mechanic (Junction Table for M:N Relationship between Service and Mechanic) = |
| 35 | Service ID – serial (Foreign Key to Service) |
| 36 | Mechanic EMBG – numeric (Foreign Key to Mechanic) |
34 | | === 5. Item |
35 | | * item_id - serial (Primary key) |
36 | | * description - varchar (Optional attribute) |
37 | | * unit_of_measurement - varchar (Mandatory attribute) |
38 | | * price_per_unit - numeric (Mandatory attribute) |
39 | | * tax - numeric (Mandatory attribute) |
| 38 | = 6. ServiceInvoice = |
| 39 | Invoice number – serial (Primary Key) |
| 40 | Date – date (Mandatory attribute) |
| 41 | Recipient – varchar (Foreign Key to Client) |
| 42 | Photo copy – varchar (Mandatory attribute) |
41 | | === 6. ServiceInvoice |
42 | | * invoice_number - serial (Primary key) |
43 | | * date - date (Mandatory attribute) |
44 | | * recipient - varchar (Foreign key referencing Client.telephone_number, Mandatory attribute) |
45 | | * photo_copy - varchar (Mandatory attribute) |
| 44 | = 7. FiscalBill = |
| 45 | Fiscal ID – serial (Primary Key) |
| 46 | DateTime – timestamp (Mandatory attribute) |
| 47 | Issuer – varchar (Foreign Key to Client) |
| 48 | Description – varchar |
| 49 | Total price – numeric (Mandatory attribute) |
| 50 | DDV – numeric (Mandatory attribute) |
| 51 | EDB – varchar (Mandatory attribute) |
58 | | 1. **Owns** - 1:N relation where each Client can have multiple Motorcycles. |
59 | | 2. **Has** - 1:N relation where each Motorcycle can have multiple Services. |
60 | | 3. **ServicedBy** - M:N relation where each Service can be performed by multiple Mechanics, and each Mechanic can work on multiple Services. |
61 | | 4. **HasInvoice** - 1:1 relation where each Service has only one Invoice and one Invoice can be linked to one Service. |
62 | | 5. **Contains** - M:N relation where each Service contains multiple Items, and each Item can be part of multiple Services. |
63 | | 6. **FiscalRelationship** - 1:1 relation where each ServiceInvoice can be associated with one FiscalBill and vice versa. |
| 58 | Client to Service: A Service is associated with one Client, but a Client can have many Services (1:N). |
| 59 | * Foreign Key: client_telephone_number in Service references telephone_number in Client. |
| 60 | |
| 61 | Motorcycle to Service: A Motorcycle can have many Services, but each Service is associated with one Motorcycle (1:N). |
| 62 | * Foreign Key: motorcycle_registration in Service references registration in Motorcycle. |
| 63 | |
| 64 | Service to Mechanic: A Service can be performed by many Mechanics, and each Mechanic can work on many Services (M:N). |
| 65 | * The service_mechanics table handles this many-to-many relationship, with service_id referencing Service and mechanic_embg referencing Mechanic. |
| 66 | |
| 67 | Client to ServiceInvoice: A Client can have many ServiceInvoices, but each ServiceInvoice belongs to one Client (1:N). |
| 68 | * Foreign Key: recipient in ServiceInvoice references telephone_number in Client. |
| 69 | |
| 70 | Client to FiscalBill: A Client can have many FiscalBills, but each FiscalBill is issued by one Client (1:N). |
| 71 | * Foreign Key: issuer in FiscalBill references telephone_number in Client. |