Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE TABLE [Pizza] (
- P_ID INTEGER(4) NOT NULL,
- P_NAME VARCHAR(15) NOT NULL,
- P_COMPOS VARCHAR(50) NOT NULL,
- P_COST INTEGER(3) NOT NULL,
- CONSTRAINT [PK_PIZZA] PRIMARY KEY CLUSTERED
- (
- [P_ID] ASC
- ) WITH (IGNORE_DUP_KEY = OFF)
- )
- GO
- CREATE TABLE [Employees] (
- E_ID INTEGER(4) NOT NULL,
- E_NAME VARCHAR(50) NOT NULL,
- E_BORN datetime NOT NULL,
- E_SEX VARCHAR(1) NOT NULL,
- E_ADDR VARCHAR(50) NOT NULL,
- E_TEL VARCHAR(11) NOT NULL,
- E_POST VARCHAR(30) NOT NULL,
- E_SALARY INTEGER(8) NOT NULL,
- CONSTRAINT [PK_EMPLOYEES] PRIMARY KEY CLUSTERED
- (
- [E_ID] ASC
- ) WITH (IGNORE_DUP_KEY = OFF)
- )
- GO
- CREATE TABLE [Clients] (
- C_ID INTEGER(5) NOT NULL,
- C_NAME VARCHAR(50) NOT NULL,
- C_ADDR VARCHAR(50) NOT NULL,
- C_TEL VARCHAR(11) NOT NULL,
- CONSTRAINT [PK_CLIENTS] PRIMARY KEY CLUSTERED
- (
- [C_ID] ASC
- ) WITH (IGNORE_DUP_KEY = OFF)
- )
- GO
- CREATE TABLE [Orders] (
- O_ID INTEGER(4) NOT NULL,
- O_COMPOS INTEGER(4) NOT NULL,
- O_CLIENT INTEGER(5) NOT NULL,
- O_DATE datetime NOT NULL,
- O_CASHIER INTEGER(4) NOT NULL,
- O_COOK INTEGER(4) NOT NULL,
- O_COURIER INTEGER(4) NOT NULL,
- CONSTRAINT [PK_ORDERS] PRIMARY KEY CLUSTERED
- (
- [O_ID] ASC
- ) WITH (IGNORE_DUP_KEY = OFF)
- )
- GO
- ALTER TABLE [Orders] WITH CHECK ADD CONSTRAINT [Orders_fk0] FOREIGN KEY ([O_COMPOS]) REFERENCES [Pizza]([P_ID])
- ON UPDATE CASCADE
- GO
- ALTER TABLE [Orders] CHECK CONSTRAINT [Orders_fk0]
- GO
- ALTER TABLE [Orders] WITH CHECK ADD CONSTRAINT [Orders_fk1] FOREIGN KEY ([O_CLIENT]) REFERENCES [Clients]([C_ID])
- ON UPDATE CASCADE
- GO
- ALTER TABLE [Orders] CHECK CONSTRAINT [Orders_fk1]
- GO
- ALTER TABLE [Orders] WITH CHECK ADD CONSTRAINT [Orders_fk2] FOREIGN KEY ([O_CASHIER]) REFERENCES [Employees]([E_ID])
- ON UPDATE CASCADE
- GO
- ALTER TABLE [Orders] CHECK CONSTRAINT [Orders_fk2]
- GO
- ALTER TABLE [Orders] WITH CHECK ADD CONSTRAINT [Orders_fk3] FOREIGN KEY ([O_COOK]) REFERENCES [Employees]([E_ID])
- ON UPDATE CASCADE
- GO
- ALTER TABLE [Orders] CHECK CONSTRAINT [Orders_fk3]
- GO
- ALTER TABLE [Orders] WITH CHECK ADD CONSTRAINT [Orders_fk4] FOREIGN KEY ([O_COURIER]) REFERENCES [Employees]([E_ID])
- ON UPDATE CASCADE
- GO
- ALTER TABLE [Orders] CHECK CONSTRAINT [Orders_fk4]
- GO
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement