Hey guys i am currently working on a school assignment.
I need to make a database that registers school students and their sport events. But with a twist:
One student can only have one event per day. But there can be multiple different students on each day.
I have made the date a primary key since my teacher said that was the solution, but it isn't.
Now i can plan one event on a date, and nothing else on that date.
This is my database:
This is my first time asking a question about mysql so please correct me if i'm doing anything wrong.
Thanks!
Related
I am building a student database for a high school. I have been able to solve most of my problems with the exception of one.
The tables I currently have are for records of the current school term. I am trying to find a way to permanently keep records for the first term, second term, third term and even after the student graduates. Student information will still be stored in the database permanently.
Please can anyone give me an idea of how I should build it?
Add a field "Term", where you write the term, which this record is for.
I think the most logical way is to have Year (calendar year) and Term (semester term: Spring, Summer, Fall) fields associated to each student. This way you could fully distinguish attendance by either calendar year or term. For graduation status you could add either graduation flag or graduation date, or both.
ADDED:
In response to comment below. Yes, I think it does make more sense to track prospective students and enrolled academic students separately. You either can track those in a stand along table or implement additional fields to the existing table. As an example, you could have a field person_status as enrolled, graduated, prospective.
Your ultimate structure really depends on what level of detail you try to achieve.
I am working on an application that awards the top person of each category for being first. The way you become first in a category is by having the most number of votes in the past 30 (or so) days. So even if you had a total of 2,000 votes but got only 2 votes within the past 30 days, someone with 10 votes but got all 10 within the past 30 days would be ranked above you. I am just trying to seek advise on the best way to create this type of system with a MySQL database and how to structure the database.
I am pretty unsure of the best way to go about this, any advice would be greatly appreciated!
The first desicion you have to make is, whether you want to keep a record for every vote cast: This has the potential for a huge table, but it lets you keep a lot of information, so you trade storage and performance against information. This must be answered by business logic, not implementation.
Assuming you DO want to keep every vote, keep it with a timestamp and the only thing you have to do is to join the user person table with the vote table, use a WHERE clause to select only the last N days and a COUNT() aggregate to count your votes.
If you do NOT want to keep every vote, you should have an accumulation table with person, day and votecount - an analogous query with SUM() instead of COUNT() will do what you want.
So i am having a little trouble in coming up with the entity-relationships for my database however i have some of the design process done be that of minimum caliber. The database will be created so that students can have many courses many to many relationship (obvious i know). The database will need to keep track of homework and attendence daily. However, classes can be just one day of the week or many days.
advisors->(advisorid, firstname, lastname, phone , email)
students->(studentid,firstname, lastname, phone, email)
courses->(courseid, description, startdate, statetime, room)
studentscourses->(studentid, courseid)
Here i am stuck, i am thinking of creating a calendar table, but how will i correlate the data to the homework table and with attendance. If any suggestions that would be great criticism is welcome.
You need to create some more entities to achieve an efficient database design. One solution would be:
Attendance(id,student_id,course_id,date)
Homework(id, course_offering_id, date) -- course_offering_id: primary key of student courses
-- since many to many relation lies between homework and student
Homework_Student(id, homework_id, student_id)
U can expand the studentscourses table to add more columns like
Studentcourses->(studentid,courseid,attendence(bool),datetime,homework(text),previoushomework(bool))
attendence will be true if the student is present on that particular date and time at which the course is scheduled.
datetime-> the date and time of the course
homework-> this shows the homework that student gets
previoushomework-> this will be true when the student has completed the homework given the previous time
This is the simplest and most compact table design u can have with this project and you can also make other relational tables according to your needs
Hope that might solve your problem
My question is more of trying to understand what and how I can get something done. Here's the thing:
I got a job to build this application for a school to manage student bio data, work-out and handle student information and basic finance management.
Based on requirements I got from meets with my client, I have an ERD of a proposed MySQL Database with 23 different tables. The one part I would like to understand quickly is displaying data based on school terms. There are 3 terms in a year, each with its own summaries at the end of each term. At the end of 3 terms, a year has gone by and a student is promoted or demoted.
So my question is, how can I render my data to show 3 different terms and also to create a new year working out how to either promote a student or make the student repeat the class its in?
23 different tables? I'd like to see that model.
I don't think you should have one table per term. You'll have to keep adding tables every term, every year.
Sounds like a transcript table should have term and year columns that are incremented or decremented as a student progresses through. It should also have a foreign key relationship with its student: it's a 1:1 between a student and their transcript.
I would have a separate transcript table because I'd prefer keeping it separate from basic personal information about a student. A transcript would refer to the courses taken each term, the grade received for each, and calculate overall progress. If I queried for the transcript for an individual student, I should be able to see every year, every term, every course, every grade in reverse chronological order.
I was looking at the following db model and I had some questions on it. I'm sure it's a good design as the guy behind it seems to be reasonably well qualified, although some things don't make sense:
Why's he seperated out bidders and sellers? I thought you'd have users, and users can place bids and sell items. You'd have a bids table with a reference to user, and a auctions table, with reference to user table. He talks a lot in his tutorials about making sure models are scalable and ready for change (don't have a status column for instance, have statuses in another table and reference that) so what's up here?
Why are their fields like "planned close date" and "winner". Isn't this data duplication, as the planned close date could be calculated using the last bid time (for acutions that use auto extend) and the winner is simply the last bid when the auction closes..?
FYI: I'm trying to build my own auction site in PHP/MySQL from scratch and it's proving to be quite difficult, so tutorials on this would be great!
Thanks!
Why's he seperated out bidders and sellers?
Each table has unique columns specific to each one, so he keeps them separate. I would actually go with user and sub-type bidder and seller to the user, like:
TABLE User (UserID (PK), ... all common fields for any user)
TABLE Bidder (UserID (PK,FK) ... all fields specific to bidders)
TABLE Seller (UserID (PK,FK) ... all fields specific to sellers)
Concerning "planned close date" and "winner":
Yes, it is data duplication, but in some cases you have to live with that in order to scale properly.
Of course you can use the last bid time from the "Bids" table to calculate the close date of the auction, but if your site gets really big, you don't want to calculate this every time someone loads the "auctions ending soon" list - because you have to calculate it for every single active auction, every time, just to find the few ones that are ending soon.
(and this list will get loaded a lot, believe me!).
Same with the winner - it's just faster to load if you have the information in the auctions
table, so you don't always have to join the "Bids" table and get the user from the last bid of every auction.
Think of the page in "My eBay" which shows all the auctions you won in the last 60 days - you would have to search all the bids of all auctions for the winner every single time someone loads this list!
A perfectly normalized database isn't always the best solution if you expect it to scale with lots of users.