Create a Relational Model the CREATE TABLE statements for th
Create a Relational Model (the CREATE TABLE statements) for the following database: We have students; each student has a unique Id, name, address, gender, and overall GPA (has default value of 0). Each student must have one major (mandatory attribute) and optionally one minor. The model must check that the gender takes values either \"Male\" or \"Female\" We have courses, each course has a unique Courseld, title, and number of credits Students will register in courses in certain semesters. We need to keep track of the grade that a student has received in a given course. The model should allow a student to take the same course in different semesters. Your CREATE TABLE statements should clearly indicate the following: 1) The attribute names and their data types (choose appropriate types), 2) The primary keys in each table, 3) The NULL (or NOT NULL) and the DEFUALT constraints, 4) The CHECK domain constrains, and 5) The foreign key constraints.
Solution
==> create table students ( SID number(5) UNIQUE, NAME varchar2(10), ADDRESS varchar2(20),
GENDER varchar2(6) NOT NULL, CGPA number(5) DEFAULT 0, CID number(5), PRIMARY KEY(sid,cid),
CHECK(gender = \'MALE\' or \'FEMALE\'));
==> create table courses ( CID number(5) UNIQUE, TITLE varchar2(10), CREDITS number(5),
FOREIGN KEY(cid) REFERENCES students(cid));
--> The above two create table statements will staisfy all your conditions and will create the tables in the database.
----> the second table is courses table which is having cid (course id), title , no of credits
