can you really store several value in database column. if so which sort i ought to use? and thru my java code how do i place the values.

for instance i wish to possess a column "language" which could store values like java, c++, c# etc. for any single row.

EDIT : i wish to possess a table known as student with the details about students having a column to keep what they are called of languages they know.

You need to produce a table "language" with the different languages you need to use, after which make use of a foreign answer to connect to this table from the LanguageID column inside your other table.

Edit: If you would like a lot more than 1 language for any given record then you will have to also produce a connecting table which links the record to some given LanguageID. You'll be able to put a variety of different languages set for confirmed record by creating new records within the connecting table.

Storing several values in one column is generally not recommended, because it violates the concepts of database normalization.

Out of your description it may sound like you've got a many-to-many relationship. Applying it by storing several values inside a column would pressure you to definitely continue to work harder than necessary without notice to update the column, or query with a language.

It's technically easy to think about a workaround (as Telcontar recommended, for instance), but I would suggest reading through a little concerning the different normal forms, and reconsidering the database design.

Knowing about database design and wish to eliminate this additional language table the usual "good" method of doing it you should use for instance a string.

Within the string keep your ISO language code that is somethink like "en-en" (first country, second language variant") plus a separator token, clearly space may well be a good one to ensure that "en-en p-p " for british and german.

After that you can make use of the "like" operator about this string column for complex multi language matching.

As a professional and know your work you are able to refer to this as an optimisation. You are a new then you definitely clearly did not understand what you done and exactly what the "relation" in relational database systems mean.

Make use of a join table (also known as chain table) to define n-m relations.

User table (pseudo-SQL):

    name VARCHAR

Language table (pseudo-SQL):

CREATE TABLE language {
    name VARCHAR

Join table for customers and languages (pseudo-SQL):

CREATE TABLE user_language {
    language_id INTEGER FOREIGN KEY REFERENCES language(id)

By doing this you can easily get all languages by user ID (and all sorts of customers that are associated with a particular language). Some RDBMS supports retrieval of individuals values like a SQL ARRAY type that you simply consequently can acquire by [cde] in one query. In PostgreSQL for instance that you can do the next query:


which you'll handle in JDBC the following:

    FROM language l
    JOIN user_language ul ON = ul.user_id
    WHERE = language_id) AS languages
FROM user u

Would you mean an enumeration, where only certain values may be used, or would you mean storing several value inside a column for any given row?


while ( {
    Long id = resultSet.getLong("id");
    String name = resultSet.getString("name");
    Object[] languages = resultSet.getArray("languages").getArray();
    // Cast to String[] or convert to List<String> or so yourself.

Multiple Values

Don't do that, make use of a many-to-many relationship rather:

-- Works in MySQL for sure
table whatever (
  language enum('JAVA','C++,'C#') NOT NULL DEFAULT 'JAVA'