Untitled

mail@pastecode.io avatar
unknown
plain_text
3 months ago
921 B
2
Indexable
Never
-- Create STD_ADD table
CREATE TABLE STD_ADD (
    Roll_no INT PRIMARY KEY,
    Address VARCHAR(50),
    Place VARCHAR(50),
    Pin VARCHAR(10)
);

-- Create STD_MARKS table
CREATE TABLE STD_MARKS (
    Roll_no INT,
    Subject VARCHAR(50),
    Exam_date DATE,
    PRIMARY KEY (Roll_no, Subject, Exam_date),
    FOREIGN KEY (Roll_no) REFERENCES STD_ADD(Roll_no)
);

-- Insert data into STD_ADD table
INSERT INTO STD_ADD (Roll_no, Address, Place, Pin)
VALUES
    (101, '123 Main St', 'New York', '10001'),
    (102, '456 Elm St', 'Los Angeles', '90001'),
    (103, '789 Oak St', 'Chicago', '60601'),
    (104, '101 Pine St', 'Houston', '77001');

-- Insert data into STD_MARKS table
INSERT INTO STD_MARKS (Roll_no, Subject, Exam_date)
VALUES
    (101, 'Mathematics', '2024-03-20'),
    (102, 'Science', '2024-03-21'),
    (103, 'English', '2024-03-22'),
    (104, 'History', '2024-03-23');
Leave a Comment