Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Mssql Datatypes

mssql

  • Please log in to reply
15 replies to this topic

#13 Tonchi

Tonchi

    Helping the world with programming

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1249 posts
  • Location:Zagreb
  • Programming Language:C#, Others
  • Learning:C, C++, Python, JavaScript, Transact-SQL, Assembly

Posted 23 June 2012 - 09:13 AM

here...this is image how it should look

http://s13.postimage...7b/Untitled.png
  • 0

Microsoft Student Partner, Microsoft Certified Professional


#14 kernelcoder

kernelcoder

    CC Devotee

  • Expert Member
  • PipPipPipPipPipPip
  • 990 posts
  • Location:Dhaka
  • Programming Language:C, Java, C++, C#, Visual Basic .NET
  • Learning:Objective-C, PHP, Python, Delphi/Object Pascal

Posted 23 June 2012 - 09:19 AM

As of the image, you want to see all the records for particularly for John, right? You can see those records by SELECT query.
SELECT * FROM students WHERE Name='John';

But what I suggest you is that you should keep two tables -- one for students info and another for their grades. So 'students' table will have all the information when a student gets admitted. As example, student id, first name, last name, email, phone number, address etc. And the grades table will have the student id, course no, grade, date of exam etc.

{students} : <student_id, first_name, last_name, email, phone, address>
// here student_id might be primary key

{grades}: <student_id, course_no, exam_date, grade>
// here student_id and course_no might be unique key

  • 0

#15 Tonchi

Tonchi

    Helping the world with programming

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1249 posts
  • Location:Zagreb
  • Programming Language:C#, Others
  • Learning:C, C++, Python, JavaScript, Transact-SQL, Assembly

Posted 23 June 2012 - 09:28 AM

I will test in SQL Server is that what I need
  • 0

Microsoft Student Partner, Microsoft Certified Professional


#16 Luthfi

Luthfi

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1320 posts
  • Programming Language:PHP, Delphi/Object Pascal, Pascal, Transact-SQL
  • Learning:C, Java, PHP

Posted 23 June 2012 - 10:26 AM

I was thinking that I didn't explain it well. So...Imagine that you are working in the school as a teacher. Insteaed of stupid grade books you have a small application for managing the grades of each student. Now, during the school year you are entering the grades for students. After the year has ended, you want to see every single grade from every / one student. I have indetical problem, but not for a students :)
Now if I'm using update statement in my database, my previous records would be deleted. Correct me if I am wrong. I don't want of those records to be deleted, I want to see them all in one table in application.
I hope that I have clear that :)


Then don't use UPDATE operation. Use INSERT instead. To properly order the grade based on the time they were entered, you need to add another field for this. This new field could be a TIMESTAMP or DATETIME. If you choose to use DATETIME, give it GetDate() for its default value, in order for the new field to not affect existing INSERT or UPDATE sql. TIMESTAMP fields will automatically updated/filled with the time the record got updated/inserted.

When querying you can simply use something like this (not tested):

SELECT Name, SurName, Grade FROM Grades ORDER BY Name, SurName, NewFieldName

If you want to see newest grade first, simply add DESC in the end of the above query.
  • 0





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download