Answer the following questions: What is the difference between float and decimal
ID: 3728385 • Letter: A
Question
Answer the following questions:
What is the difference between float and decimal data types in SQL? (10 points)
What is the difference between binary strings and character strings in SQL? When does it make sense to use one type or the other? (10 points)
What is the difference between BLOB and CLOB? Give examples of data that can be stored in each type. (10 points)
In SQL, can you set a column that allows null values to be unique? What happens if the table contains multiple rows with null value for that column? What happens in case you specify a foreign key to that column in another table and a tuple in the referencing table contains a null value for the foreign key? (30 points)
In SQL, can you specify a foreign key to non-unique columns? Why or why not? (20 points)
Include the references to all the answers you provided. (20 points)
Explanation / Answer
What is the difference between float and decimal data types in SQL? (10 points)
Answer:
The basic difference between Decimal/Numeric and Float :
Float is Approximate-number data type, which means that not all values in the data type range can be represented exactly.
Decimal/Numeric is Fixed-Precision data type, which means that all the values in the data type range can be represented exactly with precision and scale.
Converting from Decimal or Numeric to float can cause some loss of precision. For the Decimal or Numeric data types, SQL Server considers each specific combination of precision and scale as a different data type. DECIMAL(2,2) and DECIMAL(2,4) are different data types. This means that 11.22 and 11.2222 are different types though this is not the case for float. For FLOAT(6) 11.22 and 11.2222 are same data types.
What is the difference between BLOB and CLOB? Give examples of data that can be stored in each type
Answer:
BLOB:
A binary large object (BLOB) is a data type that can store binary objects or data. Binary large objects are used in databases to store binary data such as images, multimedia files and executable software code.
A binary large object may also be known as a basic large object.
Binary large objects are primarily used in all database software. Generally, database software classifies binary large objects into two types: semi-structured data and unstructured data. XML files are categorized as semi-structured data, whereas images and multimedia data are unstructured data types. Both of these BLOBs are generally not interpretable by the database.
BLOBs are used mainly for storing pictures, sounds and multimedia files, so they have a comparatively larger size than most data types and can contain up to gigabytes of data. Besides databases, the term BLOB may also refer to a visual image in computer graphics that has a unique shape.
CLOB:
A character large object (CLOB) is a large block of text stored in a database in some form of text encoding. Oracle and IBM DB2 database provide explicit support for CLOBs, though other databases can manipulate large amounts of text in some way. CLOBs can be very large, up to two gigabytes or larger.
A character large object, also known as a CLOB, is similar to a binary large object (BLOB) in that they are both large amounts of data. The key difference is that a CLOB is stored using a text encoding method such as ASCII or Unicode. CLOBs are supported in Oracle and IBM DB2, though some databases cannot use certain commands such as “LIKE” on CLOBs. Other databases support text, memo or long character fields. CLOBs can encompass long documents such as books. They can range up to two gigabytes in size or even more. Some databases store CLOBs by referencing out-of-table data
The main differences between BLOB and CLOB are:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.