1️⃣ Creating the Students Table
I began by creating a Students table with fields for StudentID, StudentName, Dept, and Email.
StudentID → Primary Key
StudentName → NOT NULL
Email → UNIQUE
📸 Screenshot:
2️⃣ Inserting Student Records
Next, I inserted three students into the table, each from different departments.
📸 Screenshot:
3️⃣ Altering the Table – Adding PhoneNo
Later, I realized I needed a Phone Number column, so I used the ALTER TABLE command to add a new column that can store a 10-digit phone number.
📸 Screenshot:
4️⃣ Adding Constraints to Courses
To practice constraints, I tried modifying the Courses table so that Credits must be between 1 and 5.
👉 Since my Courses table didn’t exist yet, Oracle threw an error – a reminder to always create the table first!
📸 Screenshot:
5️⃣ Creating a View – StudentCoursesView
Finally, I wrote a query to join Students, Courses, and Enrollments and created a view named StudentCoursesView to display StudentName, CourseName, and Grade.
📸 Screenshot:
Top comments (0)