0% found this document useful (0 votes)
42 views4 pages

Exercise-3 - Creating and Managing Tables

Uploaded by

nationalnfsu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views4 pages

Exercise-3 - Creating and Managing Tables

Uploaded by

nationalnfsu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

CTBTCSE SIII L2 - SQL Creating and Managing Tables

(Creating and Managing Tables)

Note :

✓ Create table with following field name and apply appropriate constraints.
✓ Create individual .SQL file for each SET, It must be text file.
SET-1
DEPARTMENTS (DEPTNO, DNAME, LOC)
EMPLOYEES (EMPNO, ENAME, JOB, MGR, BIRTHDATE, HIREDATE, SALARY, COMM,
DEPTNO)
SALGRADE (GRADE, LOSAL, HISAL)
Constraints
• Age must be more than 21 years
• Salary must be more than 1000 and default 5000
• DeptNo of Department is Primary Key and Deptno of Employee is Foreign Key

SET-2
Salespeople (Sno,Sname,City,Comm)
Customer (Cust_No,Cust_Name,City,Rating,Sno)
Orders (Ord_Num,amt,odate,Cust_No,Sno)

Constraints
• Cust_No must start with C and then must contain at least 4 digit.
• Salespeople and customer must not belong to Peshavar
• Customer Rating must be greater than 100 and less than 200
• Default order date is current date.

SET-3
CUST (Custno, cname, address, state, email, phone)
ITEM (Itemno, Itemname, Itemprice, Qty_hand)
INVOICE (Invno, invDate, Custno)
INVITEM (Invno, Itemno, Qty)

Note: Create above tables with necessary constraints like PK, FK, Check, Not Null and
Unique

SET-4
Competition (Comp_code, Comp_name (Dancing, Painting, GK, etc.) )
Participants (Part_no, Part_name, DOB, Address, EmailID, Contact_number )
Scorecard (Part_no, Comp_code, Judge_no [1, 2, 3], Marks)

Constraints:
• Comp_Code must start with ‘C’ must contains at least 4 digits.
• Part_No must start with ‘P’ and must contains at least 4 digits.
• Email_id must contains @
• Contact_number must be 10 digit and unique
• Judge_no should be between 1 and 3.
• Marks must be between 0 and 50
• In Scorecard part_no and comp_code should be foreign key

School of Cyber Security and Digital Forensics, NFSU, Gandhinagar Page 1


Prepared by: Dr. Parag Shukla-Assistant Professor Email: [email protected]
CTBTCSE SIII L2 - SQL Creating and Managing Tables

SET-5
APPLICANT (aid, aname, addr, birth_dt, Email, Mobile)
ENTRANCE_TEST (etid, etname, max_score, cut_score)
ETEST_CENTRE (etcid, location, incharge, capacity)
ETEST_DETAILS (aid, etid, etcid, etest_dt, score)

Constraints
• aid, etid and etcid primary key
• Email must be valid as well as unique
• Mobile must be a 10 digit and unique
• Composite Primary key in ETest_Details.
• Default etest_dt is current date

SET-6
Customer (Cust_Id, Cust_Name, Cust_Addr, Cust_City, EmailID,Contact_No)
Magazine (Mag_Id, Mag_Name, Unit_Rate, Type_of_subsciption[weekly, monthly, etc.])
Subscription (Cust_Id, Mag_Id, start_date, end_date)

Constraints:
• EmailID must be unique and must contains first 5 letters of cust_name
• Contact_no must be unique and must be exact 10 digit
• Types_of_subscription must be weekly, monthly, daily, quarterly.
• End_date must be greater than start_date

SET-7
Supplier (sid, sname, contactnum)
Parts (pid, pname, color, unit rate)
Catalog (sid, pid, qty)

Constraints:
• Supplier id must start with ‘S’ and then must contains at least 4 digits.
• Part ID must start with ‘P’ and then must contains at least 4 digits.
• Contactnum must be unique and 10 digit
• Unit_Rate must be >0
• sid and pid of catelog is foreign key

SET-8
Movie (movie_id, movie_name, date_of_release)
Screen (screen_id, location, max_capacity)
Current (movie_id,screen_id, date_of_arrival, date_of_closure)

Constraints
✓ Value of screen_id must with letter ‘S’.
✓ Screen location can by any one of ‘FF’, ‘SF’, and ‘TF’.
✓ Date_of_arrival must be less than Date_of_closure.
✓ Max_capacity attribute should have a value greater than 0.

School of Cyber Security and Digital Forensics, NFSU, Gandhinagar Page 2


Prepared by: Dr. Parag Shukla-Assistant Professor Email: [email protected]
CTBTCSE SIII L2 - SQL Creating and Managing Tables

SET-9
Team Master (Team_Id, Team_Name)
Player Master (Team_Id, Player_Id, Player_Name, Birth_Date)
Bowler (Team_Id, Bowler_Id, Over, Maiden, Run, Wicket)
Batsman (Team_Id, Player_Id, Score, Out_type, Baller_Id, Bteam_Id)
Extra_run(Team_Id, Wide_Run, No_run, Bye_Run, Legbye_Run)

Note: apply appropriate constraints

SET-10
ItemMaster (Item_Cd, Item_Name, It_Stock, Item_Unit, Item_Price)
CustMaster (Cust_Code, Cust_Name, Cust_Addr, Due_Amount)
Bill Master (Bill_No, Bill_Date, Cust_Code)
BillTran (Bill_No, Item_Cd, Item_Qty)

Note: apply appropriate constraints

SET-11
Account (ac_no, ac_name, act_type)
Transaction (ac_no, trans_date, tran_type, tran_amount, balance)

Constraints:
Act_type may be ‘S’ for saving or ‘C’ for current and tran_type may be ‘D’ for deposit or
‘W’ for withdrawal. Amount must be >0.

SET-12
Programmer (Pid, Pname, DOB, Email, Mobile, DOJ, Sex, Proficiency, Sal)
Software (Sid,Pid, title, dev_in, scost, dcost, sold)
Studies (CourseID, CourseName, SPlace, ccost, Pid)

Constraints
• Programmer must be 21 years old
• Email must be valid and unique
• Mobile must be of 10 digit and unique.
• Sex either ‘M’ or ‘F’
• Proficiency should be either Android, Java or Oracle
• Sal must be greater than 3000 and default salary is 5000
• All type of cost must be greater than 0

SET-13
DOCTOR (DNO, DNAME, SPECIALIZATION, CLINIC_ADDR)
MEDICINE (MNO, MNAME, TYPE, CONTENT, MANUFACTURER)
DISEASE (DISEASE_NAME, SYMPTOM1, SYMPTOM2, SYMPTOM3)
TREATMENT (TNO, DNO, DISEASE_NAME, MNO, DOSAGE, AVG_CURE_TIME)

Create the above tables with appropriate constraints

School of Cyber Security and Digital Forensics, NFSU, Gandhinagar Page 3


Prepared by: Dr. Parag Shukla-Assistant Professor Email: [email protected]
CTBTCSE SIII L2 - SQL Creating and Managing Tables

SET-14
STUDENT ( SNO, SNAME, SPECIALISATION, LEVAL, AGE)
CLASS( CLASSNAME, CLASSTIME, ROOMNO, FNO)
ENROLLED(SNO, CLASSNAME)
FACULTY(FNO, FNAME, DEPTNM)

Primary key and the foreign key should be added as per basic requirements and also
Following Constraints should be added.

a. Leval fields has values like ‘JR’ for junior and ‘SR’ for senior.
b. Age cannot be more than 18 years.
c. Room number starts with ‘R’ e.g. R101 etc..
d. Specialization field has valid values like ‘Database’, ‘Networks’, ‘Multimedia’,’Maths’.
e. Class time should be in the range 10.00 am to 4.45 pm.

SET-15
HOSTEL (HNO, HNAME, HADDR, TOTAL_CAPACITY, WARDEN)
ROOM (HNO, RNO, RTYPE, LOCATION, NO_OF_STUDENTS, STATUS)
CHARGES (HNO, RTYPE, CHARGES)
STUDENT (SID, SNAME, SADDR, FACULTY, DEPT, CLASS, HNO, RNO)
FEES (SID, FDATE, FAMOUNT)

The STATUS field tells us whether the room is occupied or vacant.


The charges represent the term fees to be paid half yearly.
A student can pay either the annual fees at one time or the half yearly fees twice a year.

a. Create the above given tables with all necessary constraints.


b. Insert proper data (at least 3 appropriate records) in all the tables.
c. Add a check constraint to the room table so that the room type allows the following
values only – ‘s’ for single, ‘d’ for double, ‘t’ for triple and ‘f’ for four-seater.

School of Cyber Security and Digital Forensics, NFSU, Gandhinagar Page 4


Prepared by: Dr. Parag Shukla-Assistant Professor Email: [email protected]

You might also like