Wednesday, February 13, 2013

What are Domains

What are Domains ?
  • Domains are pools of values from where values appear in the column of a table
  • Domain of a column is KIND of value it can represent
  • Column: domain- it defines the kind of values the column represents
  • Data type and domain are two different things
  • Data type is a physical thing while domain is a logical thing. 
  • I said, domain is a all possible collection of values that a column can contain, in this example, you have one perspective why I said so! 
  • Say, Staff no column has 4 values in it- 01K28, 01B23, 03X98 and 09Y12 (well, I can’t say what they really mean)! The domain of Staffno is {01K28, 01B23, 03X98 and 09Y12}.
  • I also said that domain represents the kind of data it represents. The following example will simplify the statement. 
  • Say, Street name and Student name are two columns of a table. They can both have the same data type like TEXT or CHAR or VARCHAR or whatever…can’t they? But they are different. Aren’t t. 
  • Again, say, there are two columns in a table named roll number and salary having the same data type INTEGER, NUMBER or whatever…but they are different, no? 
  • So, student name and street name have different domains and roll number and salary have different domains. 
  • In these two example, you can see the difference between data type and domain as well. Can’t you?hey?
  •  
Deep into domains
  1. Now, we will dig into deep of the domain and data type concept 
  2. Sometimes, you will need to compare between columns of two tables. Then, you will need the concept of domain.
  3. In a database the domain integrity is defined by
1.Data type and length
2.NULL value acceptance
3.Allowable values through rules
4.Default value
Constraints
Domain constraints are rules that define legal values for columns. Sometimes more than one rule is needed for a column to completely define the legal valuesUnfortunately, SQL and other database engine generally don’t facilitate with powerful tools to recognize violations on domains. If employee ID and Salary are both NUMBERs then, if you make a query by relating them, they will certainly give you an answer! Aweful, huh?  But some tools can still be easily manipulated to avoid the violations.

No comments:

Post a Comment

Vision