.TH domain "" "" "/rdb Command" .PC "Display invalid values in a column" \fBdomain \fIdomaintable \fB[\fIstring ...\fB] [< \fIone-column-table\fB]\fR .PP .II "table^validate" .II "validate table" .II "domain table" The command .B domain displays all strings or all rows in .I one-column-table that do not match any entry in the .IR domaintable . .PP .B domain is useful for validating that each item in a column is legitimate. First, build a file that consists of a list of all legal values. In relational theory, these values are called the .I domain of the column. (You can also use the command .B validate to validate numbers and short lists of valid strings.) .PP To check the domain of a column in a multicolumn table, simply use the command .B column to project the column you want. .PP The .I domaintable must be sorted because it be searched by the command .B search using the binary fast-access method (\fB\-mb\fR). .B domain is a shell script, so you can edit it to change its search method, .SH Example You might have an order file for cars like this: .DM Qty Model Colors Options ------- ------- ------- ------- 1 sedan black 3 1 sedan green 1 1 sedan farble 4 3 sedan red 5 2 convert white 1 1 sedan purple 2 1 sedan yellow 4 3 convert blue 2 .DE .PP You would also need a sorted file of possible car colors: .DM Colors ------ black blue carmel green purple red silver white .DE .PP Now we can validate the .B Color column and see all unacceptable colors: .DM column Colors < orders | domain colors .DE .PP This produces the following output: .DM Colors ------ farble yellow .DE .PP .B domain complains about .B farble and .B yellow because neither color is in our domain list. .PP You can invoke .B orders in the text editor and edit it, or add those colors to the approved list. In .B vi use the .B /pattern command to find all of the .I patterns in the orders file. Another approach is to type something like this: .DM :g/farble/s//purple/g .DE .PP This .B vi command will find all instances of .B farble and change them to .BR purple . .PP You can also validate strings written on the command line. For example, the command .DM domain colors red blue purple farble yellow green .DE .PP also prints the output: .DM farble yellow .DE .PP These command-line stings should be quoted if they have any special characters in them. They are sought by the command .BR grep . If they contain a dollar sign `$', it should be protected with three backslashes: this expression is scanned both by the shell and by .BR grep , and it takes three backslashes to get one backslash through to .BR grep . .SH "See Also" .B column, search, validate, ve .R .br COHERENT Lexicon: .B egrep, grep, sort, uniq .R .SO domain