Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,280 members, 7,807,939 topics. Date: Wednesday, 24 April 2024 at 11:13 PM

Help Designing A Database Table For A Cbt App - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Help Designing A Database Table For A Cbt App (1269 Views)

Help:i Want To Build A Cbt Exam Based App / How To Make A Database On Server? / How Do I Search Multiple Tables In A Database For A Query? (2) (3) (4)

(1) (Reply)

Help Designing A Database Table For A Cbt App by netesy(m): 10:15pm On Mar 26, 2015
Please i need help in modifying or remaking the database so that i can mark answers to questions immediately.
The problem is some courses have 50 questions, while others have 100.

How can i design the db to have answers to questions for each year and course separately?
here is my existing database sql structure

CREATE TABLE "Answer" (
"ans_id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL ,
"year_id" INTEGER NOT NULL ,
"course_id" NOT NULL,
FOREIGN KEY(year_id) REFERENCES "oXHFcGcd04oXHFcGcd04_year"(year_id) ,
FOREIGN KEY(course_id) REFERENCES Course(name)
);

CREATE TABLE "Course" (
"course_id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL ,
"name" VARCHAR NOT NULL ,
"year_id" INTEGER NOT NULL,
FOREIGN KEY(year_id) REFERENCES "oXHFcGcd04oXHFcGcd04_year"(year_id)
);

CREATE TABLE "year"
(
"year_id" INTEGER PRIMARY KEY NOT NULL ,
"year" NUMERIC NOT NULL
);

1 Like 1 Share

Re: Help Designing A Database Table For A Cbt App by kudaisi(m): 10:48am On Mar 28, 2015
I don't think there is anything wrong with you table as it is. You can get the results you want depending how how you write your SQl queries.
For clarity as your table are, let's assume a scenario where you want to get all the course from 2007. You SQL query will looks a follows.


SELECT Course.course_id, Course.Name, Year.year
FROM Course
INNER JOIN Year
ON Course.year_id = Year.year_id
WHERE Year.year='2007'


The above SQL query should successfully retrieve the course id, name, year of course within 2007 as long as they exist.
Re: Help Designing A Database Table For A Cbt App by netesy(m): 12:11am On Mar 29, 2015
let say i want to get the questions to work with what i have on ground how do i design it that i can link it to each course, year and still have all 50 questions in one column?
do i have to make my questions table have all 50+ rows to works?

(1) (Reply)

Artificial Intelligence / Please Dont Open / VACANCY: Software Developer (java Enterprise-mobile Developer) WORK FROM HOME

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 9
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.