Computer Science, asked by mehreensaroya9, 11 months ago

29) create table book

BOOK ID Char(4)

Bname Varchar(15)

Author Varchar(20)

Price Decimal


a)identify the primary key of the table book also mention the suitable reason for choosing it as primary key

b)Diff bw

(1) char and varchar type

(2)DDL and DML

Answers

Answered by smrutipadhi
36

Create table Book( Book ID char(4),Bname varchar(15),Author varchar(20),Price decimal));

→ Here Book ID is the Primary Key, because the values in other fields can be repeated for example, one author can write many books. So, author name maybe repeated.

Attachments:
Answered by omegads03
20

a) Primary key is the key that uniquely identifies a record or tuple in a database table.  

In the given table BOOK ID will be the primary key of the table as book ids are unique. Only one book is there with respect to a book id. There can be more than one book with the same book name. An author can write many books and there can be more than one book with same price.  

b) (1) Difference between char and varchar:  

• Char is a fixed-length data type which stores non-unicode characters that contain data with the length varying from 0 to 255. Whereas varchar is a variable-length data type that can contain data with the length varying from 0 to 65,535.

• Char data type uses static memory allocation while varchar data type uses dynamic memory allocation.

(2) Difference between DDL and DML:

• Data Definition Language is used to create database schema whereas Data Manipulation Language is used to manipulate accessing, modifying or retrieving the data from the database.

• CREATE, ALTER, DROP, RENAME, etc are DDL commands which works on the whole table, while SELECT, INSERT, UPDATE, DELETE, etc are DML commands that works on one or more rows.

Similar questions