Hi All
I know you can set a row to be unique, but I want expand on this in that I
want the DB schema to only disallow an entry if the row isn't unique across
3 fields. Is it possible?
My DDL for this table is as follows:
CREATE TABLE `WEBSTRINGS` (
`STRINGID` INT NOT NULL AUTO_INCREMENT,
`TOKENID` INT DEFAULT 0,
`LANGID` VARCHAR(30),
`STRINGTEXT` VARCHAR(255),
`PAGEID` SMALLINT DEFAULT 0,
`GUI` TINYINT UNSIGNED DEFAULT 0,
INDEX `indxLANGID` (`LANGID`),
INDEX `indxGUI` (`GUI`),
INDEX `indxTOKENID` (`TOKENID`),
INDEX `indxSTRINGID` (`STRINGID`),
PRIMARY KEY `PrimaryKey` (`STRINGID`)
# -- can use? UNIQUE `unqSTRINGID` (`LANGID,STRINGTEXT,GUI`)
);
The 'uniquness' I need is that if there is already an entry with the same
LANGID, STRINGTEXT and GUI then don't allow the INSERT entry to go in.
Please note that I already have this kind of checking in my front-end code,
its just for when values are being poked in directly, eg via SQLyog.
Thanks
Laphan 1 3888
"Laphan" wrote: Hi All
I know you can set a row to be unique, but I want expand on this in that I want the DB schema to only disallow an entry if the row isn’t unique across 3 fields. Is it possible?
My DDL for this table is as follows:
CREATE TABLE `WEBSTRINGS` ( `STRINGID` INT NOT NULL AUTO_INCREMENT, `TOKENID` INT DEFAULT 0, `LANGID` VARCHAR(30), `STRINGTEXT` VARCHAR(255), `PAGEID` SMALLINT DEFAULT 0, `GUI` TINYINT UNSIGNED DEFAULT 0,
INDEX `indxLANGID` (`LANGID`), INDEX `indxGUI` (`GUI`), INDEX `indxTOKENID` (`TOKENID`), INDEX `indxSTRINGID` (`STRINGID`), PRIMARY KEY `PrimaryKey` (`STRINGID`) # -- can use? UNIQUE `unqSTRINGID` (`LANGID,STRINGTEXT,GUI`) );
The ’uniquness’ I need is that if there is already an entry with the same LANGID, STRINGTEXT and GUI then don’t allow the INSERT entry to go in.
Please note that I already have this kind of checking in my
front-end code, its just for when values are being poked in directly, eg via
SQLyog. Thanks
Laphan
I think you have answered your own question. Create a unique index on
three fields. See exact syntax here: http://dev.mysql.com/doc/mysql/en/CREATE_INDEX.html
-- http://www.dbForumz.com/ This article was posted by author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbForumz.com/mySQL-Unique...ict133020.html
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=444520 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Westcoast Sheri |
last post by:
Which will be a faster lookup of an item by, "color" in the following
mySQL tables: "unique key," "primary key," or just plain "key"??
CREATE TABLE myTable (
number int(11) NOT NULL default '0',...
|
by: Agoston Bejo |
last post by:
I want to enforce such a constraint on a column that would ensure that the
values be all unique, but this wouldn't apply to NULL values. (I.e. there
may be more than one NULL value in the column.)...
|
by: Laphan |
last post by:
Hi All
I know you can set a row to be unique, but I want expand on this in that I
want the DB schema to only disallow an entry if the row isn't unique across
3 fields. Is it possible?
My DDL...
|
by: bwmiller16 |
last post by:
Guys -
I'm doing a database consistency check for a client and I find that
they're building unique indexes for performance/query reasons where
they could be using non-unique indexes.
Note...
|
by: Mamuninfo |
last post by:
Hello,
Have any function in the DB2 database that can generate unique id
for each string like oracle, mysql,sybase,sqlserver database.
In mysql:-
select md5(concat_ws("Row name")) from...
|
by: Jozef |
last post by:
Hello,
When an Access program connects to a database, is there a unique connection
id? I've used the User Roster to check connections, but just wondering if
there was two machines with the same...
|
by: Miguel Isidoro |
last post by:
Hi all,
I am trying to include a xsd:unique element in my schema to make an
attribute of an element unique at the whole document level.
Consider the following xml fragment:
<Form>...
|
by: Omatase |
last post by:
I have a set of about 6 or so strings that I need to use to generate a
unique hash. This hash will become the unique key in a database so the
hash has to be the same each time I gen it for any 1...
|
by: A. Farber |
last post by:
Hello,
I'm programming a web game on OpenBSD, but am
also trying to keep in runnable on Linux and Cygwin.
I have a list of tables at which a player/kibitzer can
sit down or create a new empty...
|
by: sqlservernewbie |
last post by:
Hi Everyone,
Here is a theoretical, and definition question for you.
In databases, we have:
Relation
a table with columns and rows
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: 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,...
|
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |