Northwind-SQLite3 的一个分支,它将 Northwind 数据库打包为 Swift 模块/包。
Swift 包文档:NorthwindSQLite.swift。
注意:由于 Xcode 14/15 的一个错误,Northwind 模块还不能直接作为包依赖项添加到 Xcode 项目中。需要设置一个"本地包"。 它在常规 SPM 上下文中工作正常。
解决 Xcode 15beta 问题的步骤
用于 Xcode 的导入 Northwind 的 "LocalHelper" Package.swift
示例
// swift-tools-version: 5.7
import PackageDescription
let package = Package(
name: "LocalHelper",
platforms: [ .macOS(.v10_15), .iOS(.v13) ], // <= required
products: [
.library(
name: "LocalHelper",
targets: ["LocalHelper"]),
],
dependencies: [
.package(url: "https://github.com/Northwind-swift/NorthwindSQLite.swift.git",
branch: "develop")
],
targets: [
.target(
name: "LocalHelper",
dependencies: [
.product(name: "Northwind", package: "NorthwindSQLite.swift")
])
]
)
要仅重新导出 Northwind,请在 LocalHelper.swift 中使用此代码
@_exported import Northwind
这是 Microsoft Access 2000 Northwind 示例数据库的一个版本,已为 SQLite3 重新设计。
Northwind 示例数据库随 Microsoft Access 一起提供,作为管理小型企业客户、订单、库存、采购、供应商、运输和员工的教程模式。 Northwind 是一个优秀的小型企业 ERP 教程模式,包含客户、订单、库存、采购、供应商、运输、员工和单式记账。
MSSQL-2000 版本中的所有 TABLES 和 VIEWS 都已转换为 Sqlite3 并包含在此处。 其中包含一个预先填充了数据的版本。 如果您愿意,可以使用包含的 python 脚本向数据库中填充更多数据。
erDiagram
CustomerCustomerDemo }o--|| CustomerDemographics : have
CustomerCustomerDemo }o--|| Customers : through
Employees ||--|| Employees : "reports to"
Employees ||--o{ EmployeeTerritories : through
Orders }o--|| Shippers : "ships via"
"Order Details" }o--|| Orders : have
"Order Details" }o--|| Products : contain
Products }o--|| Categories : in
Products }o--|| Suppliers : "supplied by"
Territories ||--|| Regions : in
EmployeeTerritories }o--|| Territories : have
Orders }o--|| Customers : place
Orders }o--|| Employees : "sold by"
Categories {
int CategoryID PK
string CategoryName
string Description
blob Picture
}
CustomerCustomerDemo {
string CustomerID PK, FK
string CustomerTypeID PK, FK
}
CustomerDemographics {
string CustomerTypeID PK
string CustomerDesc
}
Customers {
string CustomerID PK
string CompanyName
string ContactName
string ContactTitle
string Address
string City
string Region
string PostalCode
string Country
string Phone
string Fax
}
Employees {
int EmployeeID PK
string LastName
string FirstName
string Title
string TitleOfCourtesy
date BirthDate
date HireDate
string Address
string City
string Region
string PostalCode
string Country
string HomePhone
string Extension
blob Photo
string Notes
int ReportsTo FK
string PhotoPath
}
EmployeeTerritories {
int EmployeeID PK, FK
int TerritoryID PK, FK
}
"Order Details" {
int OrderID PK, FK
int ProductID PK, FK
float UnitPrice
int Quantity
real Discount
}
Orders {
int OrderID PK
string CustomerID FK
int EmployeeID FK
datetime OrderDate
datetime RequiredDate
datetime ShippedDate
int ShipVia FK
numeric Freight
string ShipName
string ShipAddress
string ShipCity
string ShipRegion
string ShipPostalCode
string ShipCountry
}
Products {
int ProductID PK
string ProductName
int SupplierID FK
int CategoryID FK
int QuantityPerUnit
float UnitPrice
int UnitsInStock
int UnitsOnOrder
int ReorderLevel
string Discontinued
}
Regions {
int RegionID PK
string RegionDescription
}
Shippers {
int ShipperID PK
string CompanyName
string Phone
}
Suppliers {
int SupplierID PK
string CompanyName
string ContactName
string ContactTitle
string Address
string City
string Region
string PostalCode
string Country
string Phone
string Fax
string HomePage
}
Territories {
string TerritoryID PK
string TerritoryDescription
int RegionID FK
}
以下视图已从原始 Northwind Access 数据库转换而来。 请参阅 src/create.sql
文件以查看每个视图背后的代码。
视图名称 |
---|
[产品字母列表] |
[当前产品列表] |
[按城市划分的客户和供应商] |
[发票] |
[订单查询] |
[订单小计] |
[订单小计] |
[1997 年的产品销售额] |
[高于平均价格的产品] |
[按类别划分的产品] |
[季度订单] |
[按金额划分的销售总额] |
[按季度划分的销售额摘要] |
[按年份划分的销售额摘要] |
[1997 年的类别销售额] |
[扩展的订单详情] |
[按类别划分的销售额] |
python3 --version
)sqlite3 -help
make build # Creates database at ./dist/northwind.db
make populate
make report