Docsity

Creating a Database and Tables for Student Information and Majors, Exercises of Database Programming

Toggle sidebar
bg1
1/ Create a database called “StudentDB2”
2/ Create a table called “Majors”
Majors(majorID, majorName)
It stores the information of majors, contains columns
- majorID: char(2), primary key – major id
- majorName: varchar(50) – Name of major
3/ Create a table called “Students”
Students(studentID, firstName, lastName, age, majorID)
It stores the information of student, contains columns
- stgudentID: char(6), primary key – Student ID
- firstName: varchar(50) – First Name and middle name
- lastName: varchar(50) – Last name
- age: int - Age of student
- majorID: char(2) – Major ID
pf3

Partial preview of the text

Download Creating a Database and Tables for Student Information and Majors and more Exercises Database Programming in PDF only on Docsity!

1/ Create a database called “StudentDB2” 2/ Create a table called “Majors” Majors(majorID, majorName) It stores the information of majors, contains columns

  • majorID: char(2), primary key – major id
  • majorName: varchar(50) – Name of major 3/ Create a table called “Students” Students(studentID, firstName, lastName, age, majorID) It stores the information of student, contains columns
  • stgudentID: char(6), primary key – Student ID
  • firstName: varchar(50) – First Name and middle name
  • lastName: varchar(50) – Last name
  • age: int - Age of student
  • majorID: char(2) – Major ID

4/ Add the data into the table “Majors” 5/ Add the data into the table “Students” 6/ Display all students as follwoing table: fileds are collected from 2 tables: Students and Majos