仓库表(Warehouse):仓库编号(WarehouseID,主键),仓库名称(WarehouseName),仓库面积(WarehouseArea),电话号码(WarehousePhoneNumber) 零件表(Part):零件编号(PartID,主键),零件名称(PartName),零件规格(PartSpecification),单价(PartPrice),描述(PartDescription) 供应商表(Supplier):供应商编号(SupplierID,主键),供应商姓名(SupplierName),地址(SupplierAddress),电话号码(SupplierPhoneNumber),账号(SupplierAccount) 项目表(Project):项目编号(ProjectID,主键),预算(ProjectBudget),开工日期(ProjectStartDate) 职工表(Employee):职工编号(EmployeeID,主键),职工姓名(EmployeeName),年龄(EmployeeAge),职称(EmployeeTitle),仓库编号(WarehouseID,外键,关联仓库表) 库存表(Inventory):仓库编号(WarehouseID,主键,外键,关联仓库表),零件编号(PartID,主键,外键,关联零件表),库存量(InventoryQuantity) 供应表(Supply):供应商编号(SupplierID,主键,外键,关联供应商表),项目编号(ProjectID,主键,外键,关联项目表),零件编号(PartID,主键,外键,关联零件表) 其中,库存表和供应表是连接多对多关系的中间表。职工表和仓库表是一对多关系,职工表和职工表之间是一对多关系。它们的查询语句
时间: 2024-02-02 17:02:39 浏览: 189
以下是一些基本的 SQL 查询语句示例:
1. 查询所有仓库的名称和电话号码
```sql
SELECT WarehouseName, WarehousePhoneNumber FROM Warehouse;
```
2. 查询所有零件的名称和单价
```sql
SELECT PartName, PartPrice FROM Part;
```
3. 查询所有供应商的姓名和地址
```sql
SELECT SupplierName, SupplierAddress FROM Supplier;
```
4. 查询所有项目的编号和预算
```sql
SELECT ProjectID, ProjectBudget FROM Project;
```
5. 查询所有职工的姓名和职称,以及他们所在的仓库的名称
```sql
SELECT EmployeeName, EmployeeTitle, WarehouseName FROM Employee
JOIN Warehouse ON Employee.WarehouseID = Warehouse.WarehouseID;
```
6. 查询每个仓库中每种零件的库存量
```sql
SELECT Warehouse.WarehouseName, Part.PartName, Inventory.InventoryQuantity FROM Warehouse
JOIN Inventory ON Warehouse.WarehouseID = Inventory.WarehouseID
JOIN Part ON Inventory.PartID = Part.PartID;
```
7. 查询每个供应商所供应的每个项目和零件
```sql
SELECT Supplier.SupplierName, Project.ProjectID, Part.PartName FROM Supplier
JOIN Supply ON Supplier.SupplierID = Supply.SupplierID
JOIN Project ON Supply.ProjectID = Project.ProjectID
JOIN Part ON Supply.PartID = Part.PartID;
```
这只是一些简单的例子,您可以根据需要编写更复杂的查询语句。
阅读全文