Untitled

 avatar
unknown
plain_text
a year ago
1.3 kB
5
Indexable
-- Create the Suppliers table
CREATE TABLE Suppliers (
    sid INTEGER PRIMARY KEY,
    sname VARCHAR2(100),
    city VARCHAR2(100),
    street VARCHAR2(100)
);

-- Create the Parts table
CREATE TABLE Parts (
    pid INTEGER PRIMARY KEY,
    pname VARCHAR2(100),
    color VARCHAR2(100)
);

-- Create the Catalog table
CREATE TABLE Catalog (
    sid INTEGER,
    pid INTEGER,
    cost REAL,
    PRIMARY KEY (sid, pid),
    FOREIGN KEY (sid) REFERENCES Suppliers(sid),
    FOREIGN KEY (pid) REFERENCES Parts(pid)
);

-- Inserting data into Suppliers
INSERT INTO Suppliers VALUES (1, 'Supplier1', 'City1', 'Street1');
INSERT INTO Suppliers VALUES (2, 'Supplier2', 'City2', 'Street2');
INSERT INTO Suppliers VALUES (3, 'Supplier3', 'City3', 'Street3');

-- Inserting data into Parts
INSERT INTO Parts VALUES (1, 'Part1', 'blue');
INSERT INTO Parts VALUES (2, 'Part2', 'red');
INSERT INTO Parts VALUES (3, 'Part3', 'blue');
INSERT INTO Parts VALUES (4, 'Part4', 'green');

-- Inserting data into Catalog
INSERT INTO Catalog VALUES (1, 1, 10.0); -- Supplier1 supplies blue part
INSERT INTO Catalog VALUES (1, 2, 15.0); -- Supplier1 supplies red part
INSERT INTO Catalog VALUES (2, 3, 12.0); -- Supplier2 supplies blue part
INSERT INTO Catalog VALUES (3, 4, 8.0);  -- Supplier3 supplies green part
Editor is loading...
Leave a Comment