Question:
help regarding data base using mySQL?
enginesh
2013-08-06 08:43:16 UTC
here i want to ask is that how should i create a data base using my SQL for creating data base of students in school (like students name,DOB,address,parents phone no. roll no. ) and also that i should get for which time he is attending which lecture along with teachers data base(name,DOB,address,parents phone no. roll no.).
also i want to make the attendance cumulative. a help or suggestions will be of great help.
though i dont have much knowledge about my SQL ,i will do my best to learn it.
Four answers:
Todd
2013-08-06 19:41:23 UTC
The school database seems easy but really isn't, especially according to your business rules. There are also some things missing in your initial statement of purpose. Are lectures 9AM to 5PM or just part of that time slot? Do students attend more than one lecture in that period? Do teachers teach more than one lecture in that period? Are lectures repeated? What does "make the attendance cumulative" mean exactly? Does or can more than one teacher conduct the same lecture? The same lecture but at different times? Are lectures tied to a course or to a school of study? Do lectures become obsolete after they are no longer taught or is there a temporal history for everything taught (this question is not as obvious as it looks)? I'm sure I can think of many more.



Your initial basic setup sounds like...

- zero or more students attend zero or more lectures

- a professor gives zero or more lectures

- a lecture is part of one (or more?) classes

- a student is registered for zero or more classes

- a professor is registered to oversee zero or more classes

- a class is managed by one (or more?) professors

- a lecture is part of a time slot



Edit... Okay, I see. Your setup does seem simpler than I thought at first. By the way, cumulative is data inherent (resultant) of the attendance, so it is not something you need to input or manually keep track of.



This is not really the right venue for conversation, though, so if you want some specific help with the SQL and general approach feel free to email me at clistbucket@gmail.com. The reason why I suggest conversation over a one-way answer is because there may be other questions that come up and Y!A is terrible for communicating code.



Edit again... I'll post a basic skeleton here that, hopefully after learning SQL, will benefit you somewhat. You'll need to modify the constraints according to your business rules (time delimiters, are weeks consistent/unique?, are courses unique or just lectures, etc.) and also add pertinent columns such as date of birth and what not. Lastly, you would archive the data every semester or other unit of time whenever the schedule/catalog changes. The constraints/keys seem complicated but are there for a reason. Untested on MySQL...



CREATE TABLE academia (

school char(4) NOT NULL PRIMARY KEY,

school_name varchar NOT NULL UNIQUE

);



CREATE TABLE people (

uid int NOT NULL PRIMARY KEY,

person varchar NOT NULL,

-- the uid should be linked to whatever identification system you use

-- include data specific to all people here

);



CREATE TABLE alumni (

uid int NOT NULL REFERENCES people (uid) PRIMARY KEY

-- info specific only to students here

);



CREATE TABLE faculty (

uid int NOT NULL REFERENCES people (uid) PRIMARY KEY

-- info specific only to professors here

);



CREATE TABLE listing (

course varchar NOT NULL,

school char(4) NOT NULL,

no integer NOT NULL,

PRIMARY KEY (school, no)

-- so a course would be identified as MCEN 1020, for example

-- note, a course is independent of when it is scheduled

);



CREATE TABLE catalog (

cid integer NOT NULL PRIMARY KEY,

school char(4) NOT NULL,

no integer NOT NULL,

offering char(1) NOT NULL,

FOREIGN KEY (school, no) REFERENCES listing (school, no) ON UPDATE CASCADE,

UNIQUE (school, no, offering)

-- a course can be offered at different times and taught be different profs

);



CREATE TABLE schedule (

cid integer NOT NULL,

day integer NOT NULL,

hour integer NOT NULL,

CHECK ((day) BETWEEN 1 AND 5),

check ((hour) BETWEEN 1 and 7)

primary key (cid, day, hour)

-- the actual schedule, we assume every week is the same over the semester

-- the schedule defines what is even possible to attend

);



CREATE TABLE attendance (

uid integer NOT NULL REFERENCES people (uid) ON UPDATE CASCADE ON DELETE CASCADE,

cid integer NOT NULL REFERENCES schedule (cid) ON UPDATE CASCADE ON DELETE CASCADE,

week integer NOT NULL,

day integer NOT NULL,

hour integer NOT NULL,

role varchar NOT NULL DEFAULT 'student',

FOREIGN KEY (cid, day, hour) REFERENCES schedule (cid, day, hour) ON UPDATE CASCADE ON DELETE CASCADE,

PRIMARY KEY (week, day, hour)

-- a lecture/performance must be unique

-- a person can only be at a single lecture at any given time slot (week, day, hour)

-- the role tells in what capacity the person is there (teacher, student, overseer, etc.)

);
Jeff P
2013-08-06 17:19:58 UTC
What you are wanting to do is for more advanced users. You don't seem like you even have a basic foundation of SQL--you can't jump into a big project like this without any experience. You need to start small. I would suggest you start learning SQL from the ground up. Once you've spent a couple weeks reading up on it and practicing queries, then maybe tackle this project.
anonymous
2013-08-06 16:11:14 UTC
write sql query in mysql database as given below

create table student(name varchar2(20),DOB date,address varchar2(40),pcno int,rollno int);
clark
2013-08-06 15:49:45 UTC
you can use xampp server and open phpmyadmin from browser

localhost/phpmyadmin


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...