hii,
I have a enum field in database ,which i break up using php and make it a dropdown list in the form . i have a requirement now such that from the list the person must be able to select 2 items together which is also done.but can i store 2 values in a db column which is an enum field?
1 2718 Atli 5,058
Recognized Expert Expert
Hey.
but can i store 2 values in a db column which is an enum field?
Not with an ENUM field, no. They only accept single values in the ENUM list.
In any case, you shouldn't even attempt to do that. It violates basic RDMS design principles.
The first rule of relational database design (1NF, the 1'st Normal Form):
- Never put more than a single value into any one field.
When multiple values of the same data-type need to be linked to a single row (e.g. multiple phone numbers for a single person), the standard method is to move that column out of the main table and put it into a separate table, which is then linked to the main table using a Foreign Key.
For example: - +---------+ +--------------------+
-
| person | | phone_number |
-
+---------+ +--------------------+
-
| id (PK) |<---<| person_id (PK, FK) |
-
| name | | number (PK) |
-
| etc... | +--------------------+
-
+---------+
There a single person can be linked to multiple numbers, but only once to a each number. (The 'person_id' and 'number' would be a joint key, preventing duplicate pairs.)
The same principle holds for ENUM fields. If one row in a table needs to be linked to multiple values of the ENUM column, move it into it's own table and set up a Foreign Key link.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Pjotr Wedersteers |
last post by:
Hi
I am not even sure if it is at all possible, and I can't find the stuff I am
looking for, probably using the wrong search keys. WAMP machine (XP,
2.50.2, 4.1.5, 5.0.2)
I have a field in the MySQL table 'members':
"membertype" enum ('adult','student','senior','child','honour')
Sofar the form used for the db only has text fields,...
|
by: Charles Crume |
last post by:
Hello all;
I have used dBASE, and other computer languages/databases, for years. They
all have a logical field type. However, the version of MySQL used by the ISP
hosting my site does not support a "logical" field type.
It does support ENUM and I have set some up in a couple of tables that
accept the values 'T' and 'F'. Sometimes they...
|
by: mrhicks |
last post by:
Hello all,
I have a question about enumerations. Within some requirements data
passed back a certain bit field is defined by three bits then in
another section the bit field is defined as 4 bits. The second set is
a superset of the first set. The enumeration look as following...
enum SET1 { AutoOffState = 0x00, AutoOneState = 0x01,...
|
by: Ken Allen |
last post by:
The ToString() function, when applied to a variable that is an enumeration
type, results in a string that is the name of the enumerated value that was
defined in the source code. This is cool, but how does one override the
function to have some values return a different string?
For example, suppose I have an enum with value for the types of...
|
by: Paul E Collins |
last post by:
The help file says that "bit fields can be combined using a bitwise OR operation, whereas
enumerated constants cannot", and yet this code works:
enum Blah { a, b, c }; // without
....
Blah x = Blah.a | Blah.b;
So what is the purpose of the Flags attribute? I understand it's
potentially useful for reflection, so that (for example) the...
| |
by: Barry |
last post by:
Hi
I am trying to create a enumerator for some Color items like this
enum Colors : Color {
yellowColor = Color.FromArgb(254, 253, 21),
YellowTopColor = Color.FromArgb(254, 253, 21)
};
|
by: Andrea Williams |
last post by:
I'm working with C# and I'm setting up some ENUM's I have a data and
Business layer. I'm declaring a common enum for the Data Layer. The UI
layer references the Bus layer and the bus layer references the Data layer,
but I would like to have the enum exposed to all three. Is there a way to
trickle down that enum (Like class inheritance...
|
by: Steven Nagy |
last post by:
So I was needing some extra power from my enums and implemented the
typesafe enum pattern.
And it got me to thinking... why should I EVER use standard enums?
There's now a nice little code snippet that I wrote today that gives me
an instant implementation of the pattern. I could easily just always
use such an implementation instead of a...
|
by: Cmtk Software |
last post by:
I'm trying to define an enum which will be used from unmanaged c++, C++/CLI
managed c++ and from C#.
I defined the following enum in a VS dll project set to be compiled with the
/clr switch:
public enum Days
{
Sunday
};
|
by: Daniel Jeffrey |
last post by:
Hello.
Can anyone help me please. I have created an Enumeration, and I loop through
it, it all works ok, except the first item returns 2 times.
Code is below. When called I Get "Text Edit" 2 times
public enum CustomFieldTypes
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |