I have to create database of student having different subjects and marks in respective subjects.

Now many students will many subjects so there is many to many relationship.

My database design:
Table 1:

Student table
(PK)Stud_id, Stud_name

Table 2:

Subject table
(FK)Stud_id, Sub_id, Sub_name, Marks.

Table 3:

Stud_Sub table
Stud_id, Sub_id

1) is this design is right or wrong?

2) Secondly i want to find name of the student who scored second highest marks.

Why don't you have only (PK)Sub_id and Sub_name in Subject table
and
(FK)Stud_id, (FK)Sub_id, Marks in Stud_Sub table?

Ok so there is no need of stud_id in sec table?
other than that thing are ok in database?
But i want to calculate sec highest marks of the student.

But i want to calculate sec highest marks of the student.

You need to run query that will look up all the students with their marks of given subject. Sort them descending order and ask for second of them. So try to come with some query and if doesn't work out post it and we may have go on it.

Ok i give a try thanks , will get back to you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.