Simple enough.
The answer to your second question is Yes.
CREATE TABLE customers (
CustomerID NUMBER(8)
)
/
ALTER TABLE customers ADD CONSTRAINT customers_pk PRIMARY KEY (CustomerID)
/
CREATE TABLE Items (
ItemID NUMBER(8)
)
/
ALTER TABLE Items ADD CONSTRAINT Items_pk PRIMARY KEY (CustomerID)
/
CREATE TABLE dvouchers (
DVoucherID NUMBER(8),
CustomerID NUMBER(8)
)
/
ALTER TABLE dvouchers ADD CONSTRAINT dvouchers_pk PRIMARY KEY (CustomerID)
/
ALTER TABLE dvouchers
ADD CONSTRAINT dvouchers_Customers_FK FOREIGN KEY (
CustomerID
) REFERENCES Customers (
CustomerID
)
/
CREATE TABLE CustomerItems (
CustomerID NUMBER(8),
ItemID NUMBER(8)
)
/
ALTER TABLE CustomerItems
ADD CONSTRAINT CustomerItems_pk PRIMARY KEY (
CustomerID,
ItemID
)
/
ALTER TABLE CustomerItems
ADD CONSTRAINT CustomerItems_Customer_FK FOREIGN KEY (
CustomerID
) REFERENCES Customers (
CustomerID
)
/
ALTER TABLE CustomerItems
ADD CONSTRAINT CustomerItems_Items_FK FOREIGN KEY (
ItemID
) REFERENCES Items (
ItemID
)
/
CREATE TABLE dvoucherItems (
dvoucherID NUMBER(8),
ItemID NUMBER(8)
)
/
ALTER TABLE dvoucherItems
ADD CONSTRAINT dvoucherItems_pk PRIMARY KEY (
dvoucherID,
ItemID
)
/
ALTER TABLE dvoucherItems
ADD CONSTRAINT dvoucherItems_dvouchers_FK FOREIGN KEY (
dvoucherID
) REFERENCES dvouchers (
dvoucherID
)
/
ALTER TABLE dvoucherItems
ADD CONSTRAINT dvoucherItems_Items_FK FOREIGN KEY (
ItemID
) REFERENCES Items (
ItemID
)
/