Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to do the multivalue in mysql

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
how to do the multivalue in mysql
i need to create a table student.

it has 2 attributes ssn and course_num

course_num is a multivalue attribute,, it has all the course # that student take this semester.

but how can i make it multivalue in mysql..
thanx.
 
I would not use a multivalued column for that data. I would create a second table to store class information and a third to record the relationship between students and classes. ______________________________________________________________________
Never forget that we are
made of the stuff of stars
 
Multivalued databases are a completely different thing from SQL-based (or relational) systems. In a relational database, you would never try to place multiple values in a single column, because every column should represent a single attribute (a single fact) about it's subject. As Sleipnir said, if you have multiple values for a particular subject, then you would put those in another table, and relate that table to the main table by matching primary keys.

It is possible to place multiple values in a single SQL column, simply by making the column type TEXT of VARCHAR, and separating the values with commas (1,3,45,23), and then using your programming environment to split the data into separate values, but that is a very crude hack, and you will be sorry later, when you try to make your system portable, or more scaleable, etc... -------------------------------------------

"Now, this might cause some discomfort..."
(
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top