Q-3. Write a DDL-schema for the (new) ERD you drew in Q-1.
时间: 2024-10-27 17:12:06 浏览: 12
在Q-1中,如果你绘制了一个ER图(Entity Relationship Diagram,实体关系模型),并假设有一个包含员工、部门和项目的关系,这里是一个基本的DDL(Data Definition Language)创建表的SQL语句示例:
```sql
CREATE TABLE Department (
ID INT PRIMARY KEY,
Name VARCHAR(50),
ManagerID INT FOREIGN KEY REFERENCES Employee(ID)
);
CREATE TABLE Employee (
ID INT PRIMARY KEY,
FirstName VARCHAR(50),
LastName VARCHAR(50),
DepartmentID INT FOREIGN KEY REFERENCES Department(ID),
Position VARCHAR(50)
);
CREATE TABLE Project (
ID INT PRIMARY KEY,
Title VARCHAR(100),
ManagerID INT FOREIGN KEY REFERENCES Employee(ID),
StartDate DATE,
EndDate DATE
);
```
这个DDL分别创建了`Department`、`Employee`和`Project`三个表,通过`Foreign Key`约束确保了员工与部门,以及项目经理与项目的关联。请注意,具体的字段名、数据类型和键类型可能会根据实际情况调整。
阅读全文