wiki:RelationalDesign

Version 23 (modified by 231190, 8 hours ago) ( diff )

--

Логички и физички дизајн – Креирање база податоци (со SQL DDL)

← Назад кон почетната страница

Релациско мапирање

Ознаки

  • Примарните клучеви се означени со bold и underline.
  • Надворешните клучеви се означени со FK*, а во заграда е наведена табелата што ја референцираат.
  • Задолжителните атрибути се означени со bold.
  • Кај сложените примарни клучеви, сите атрибути што го сочинуваат клучот се означени.

Табели

  1. Customers (customer_id, name, type, tax_id, payment_terms_days)
  1. Locations (location_id, name, city, country, customer_id FK*(Customers))
  1. Users (user_id, username, email)
  1. Roles (role_id, name)
  1. Has_Role (user_id FK*(Users), role_id FK(Roles)*, assigned_on)
  1. Drivers (driver_id, first_name, last_name, embg, status)
  1. Driver_Documents (driver_id FK*(Drivers), doc_no, doc_type, expires_on)
  1. Vehicles (vehicle_id, plate, vin, vehicle_type, status)
  1. Vehicle_Documents (vehicle_id FK*(Vehicles), doc_no, doc_type, expires_on)
  1. Orders (order_id, order_no, order_date, status, customer_id FK*(Customers))
  1. Loads (order_id FK*(Orders), load_no, cargo_description, weight_kg, agreed_price, status)
  1. Stops (order_id FK*(Loads), load_no FK(Loads)*, seq_no, stop_type, planned_time, actual_time, location_id FK*(Locations))
  1. Shipments (order_id FK*(Loads), load_no FK(Loads)*, shipment_no, description, weight_kg, status, stop_order_id FK*(Stops), stop_load_no FK*(Stops), stop_seq_no FK*(Stops))
  1. Status_History (order_id FK*(Loads), load_no FK(Loads)*, changed_at, status, note, user_id FK*(Users))
  1. Assignments (assignment_id, planned_start, planned_end, status, order_id FK*(Loads), load_no FK*(Loads), driver_id FK*(Drivers), truck_id FK*(Vehicles), trailer_id FK*(Vehicles))
  1. Expenses (expense_id, expense_date, amount, note, vehicle_id FK*(Vehicles), order_id FK*(Loads), load_no FK*(Loads), assignment_id FK*(Assignments))
  1. Fuel_Entries (expense_id FK*(Expenses), liters, price_per_liter, odometer_km)
  1. Services (expense_id FK*(Expenses), service_type, workshop, odometer_km)
  1. Tolls (expense_id FK*(Expenses), road_section, country)
  1. Invoices (invoice_id, invoice_no, issue_date, due_date, customer_id FK*(Customers), user_id FK*(Users))
  1. Includes (invoice_id FK*(Invoices), order_id FK(Loads)*, load_no FK(Loads)*, amount, description)
  1. Payments (payment_id, payment_date, amount, method, invoice_id FK*(Invoices))

DDL скрипта

ddl.sql

DML скрипта

DML script.sql]

Релациски дијаграм

Attachments (3)

Download all attachments as: .zip

Note: See TracWiki for help on using the wiki.