0% found this document useful (0 votes)
7 views3 pages

Assigment 1

The document outlines the creation of a database named 'schoolDB' with several tables including students, courses, faculties, marks, department, enrollment, attendance, and library. Each table is defined with specific attributes and constraints, such as primary keys, foreign keys, and data type requirements. The structure is designed to manage student information, course enrollment, attendance tracking, and library management.

Uploaded by

cxamari8
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)
7 views3 pages

Assigment 1

The document outlines the creation of a database named 'schoolDB' with several tables including students, courses, faculties, marks, department, enrollment, attendance, and library. Each table is defined with specific attributes and constraints, such as primary keys, foreign keys, and data type requirements. The structure is designed to manage student information, course enrollment, attendance tracking, and library management.

Uploaded by

cxamari8
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/ 3

.

CREATING DATE BASE


create database schoolDB

use schoolDB

STUDENT TABLE
create table students (

student_id int primary key ,

full_name varchar(50) not null ,

age int check (age >= 18),

email varchar (100) not null unique,

p_number int not null unique

);

COURSES TABLE
create table courses (

course_id int primary key ,

course_name varchar (10) not null

);

FACULTIES TABLE

create table faculties (

faculty_id int primary key ,

faculty_name varchar (50) not null

);
MARKS TABLE
create table marks (

mark_id int primary key ,

student_id int ,

course_id int ,

score int check (score >= 0 AND score <=100),

FOREIGN KEY (student_id) references students(student_id),

FOREIGN KEY (course_id) references courses(course_id) );

DEPARTMENT TABLE
create table department (

d_id int primary key ,

d_name varchar(50) not null ,

faculty_id int ,

foreign key (faculty_id) references faculties(faculty_id)

);

ENROLLMENT TABLE
create table enrollment (

en_id int primary key ,

student_id int ,

course_id int ,

en_date date default GETDATE( ) ,

foreign key (student_id) references students(student_id),

foreign key (course_id) references courses(course_id)

);
ATTENDANCE TABLE

create table attendance (

attendance_ID int primary key ,

student_id int ,

course_id int ,

attendance_date date not null ,

a_status varchar (15) check(a_status in ('peresent','absent','late')),

foreign key (student_id) references students(student_id),

foreign key (course_id) references courses(course_id)

);

LIBRARY TABLE

create table library (

book_id int primary key ,

book_title varchar(20) not null ,

book_author varchar(20) not null ,

student_id int ,

borrow_date date default getdate() ,

due_date date not null ,

foreign key (student_id) references students(student_id)

);

You might also like