473,382 Members | 1,437 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Is it possible to create fields with multiple values?

I would like to create a database of music. An album has many values for the fields: mood, style etc.

How would I structure my tables for this situation? Is it possible to have a field with many values?
Jul 10 '10 #1

✓ answered by yarbrough40

Structure it like any other database: primary key, fields for AlbumName, SongTitle, Mood, Style, Etc....

a field with multiple values can be done but is not recommended because in large database structures you will not be able to set an efficient index on it and writing queries gets ambiguous and inefficient. for instance you could have a song with styles of Rock, Funk, and Soul. they way to do it in a single field would be to be consistant on how you separate the values like always put a colon between each ex. Rock:Funk:Soul This way when you query for it you could always use a Like '%' statement to find it as well as be able to parse out the entire string in a code behind using the colon as the delineator should you need to capture the whole field and do something with the value as a whole.

The recommended way would be to simply add an entirely new record for each like so:

Artist----------Album--------------Song-------------------Style
--------------------------------------------------------------------
Fishbone---Fishbone------Party at Ground Zero-----Ska
Fishbone---Fishbone------Party at Ground Zero-----Funk
Fishbone---Fishbone------Party at Ground Zero-----Rock

this is how databases should be structured.
enjoy!

2 2260
yarbrough40
320 100+
Structure it like any other database: primary key, fields for AlbumName, SongTitle, Mood, Style, Etc....

a field with multiple values can be done but is not recommended because in large database structures you will not be able to set an efficient index on it and writing queries gets ambiguous and inefficient. for instance you could have a song with styles of Rock, Funk, and Soul. they way to do it in a single field would be to be consistant on how you separate the values like always put a colon between each ex. Rock:Funk:Soul This way when you query for it you could always use a Like '%' statement to find it as well as be able to parse out the entire string in a code behind using the colon as the delineator should you need to capture the whole field and do something with the value as a whole.

The recommended way would be to simply add an entirely new record for each like so:

Artist----------Album--------------Song-------------------Style
--------------------------------------------------------------------
Fishbone---Fishbone------Party at Ground Zero-----Ska
Fishbone---Fishbone------Party at Ground Zero-----Funk
Fishbone---Fishbone------Party at Ground Zero-----Rock

this is how databases should be structured.
enjoy!
Jul 10 '10 #2
Personally i would create the field as varchar then you can check with a sql statement whats in the field and output the result.
Jul 10 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: eddie wang | last post by:
The following shows one value per row. How to display multiple values with a space seperator per row? Thanks. <td wrap width="371">Fields:</td> <% if not rs.EOF then do while not rs.EOF...
17
by: Roland Hall | last post by:
Is there a way to return multiple values from a function without using an array? Would a dictionary object work better? -- Roland Hall /* This information is distributed in the hope that it...
5
by: Homer Simpson | last post by:
Hi All, I'm trying to write a method where I pass three arguments and the method returns six values. All the values will be doubles. First, is it possible to get multiple values returned by a...
1
by: Kevin Bell via .NET 247 | last post by:
Hi All! I am trying to create a simple login feature for my webpage dynamically using VB.NET/ASP.NET. There are two textfields, userName and userPass, and a button, btnLogin. I want to use...
16
by: Nikolay Petrov | last post by:
How can I return multiple values from a custom function? TIA
9
by: Karl O. Pinc | last post by:
I want to return multiple values, but not a set, only a single row, from a plpgsql function and I can't seem to get it to work. (I suppose I'd be happy to return a set, but I can't seem to make...
8
by: Chris A via AccessMonster.com | last post by:
I have an interesting problem that I have yet to come accross that I can't change data structure on because it is an export from filemaker I am reformatting for another dept. anyway. I have a table...
5
by: mctime | last post by:
Hello, I am attempting to split a raw data table into a new table that has split out a specific field in the raw data and created a new record for each split but I have come to an impasse due to...
8
by: smoky_flame via DotNetMonster.com | last post by:
hi, is it possible to take multiple values(int) seperated by commas as input from textbox in C# and draw a figure using those values. e.g. drawing a simple path using 1,2,3,4 values. --...
0
by: Maric Michaud | last post by:
Le Thursday 28 August 2008 03:43:16 norseman, vous avez écrit : Disctionaries are hash tables with a unique key and constant time lookup. What you want could be implemented as a complex data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.