Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


A company wants to store their invoices in a database. They
already have their customers and articles in that database.
Both customer and article are each identified by an unique
integer value. Please create the SQL statements for
creating the necessary table(s) for storing the invoices in
a MySQL database. An invoice should hold information like
invoice number, customer, date, article(s) and quantity
etc.



A company wants to store their invoices in a database. They already have their customers and artic..

Answer / frank

Assume existing tables for customer and article are:
customers
+------------+----------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra
|
+------------+----------+------+-----+---------+----------------+
| customerId | int(11) | NO | PRI | NULL |
auto_increment |
| customer | char(50) | NO | | NULL |
|
+------------+----------+------+-----+---------+----------------+

article:
+-----------+----------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------+----------+------+-----+---------+----------------+
| articleId | int(11) | NO | PRI | NULL | auto_increment |
| article | char(50) | NO | | NULL | |
+-----------+----------+------+-----+---------+----------------+

CREATE TABLE invoices (invoiceId INT AUTO_INCREMENT PRIMARY
KEY,customerId INT NOT NULL,articleId INT NOT
NULL,invoiceNumber CHAR(20) NOT NULL UNIQUE,invoiceDate DATE
NOT NULL,quantity INT NOT
NULL,INDEX(customerId),INDEX(articleId));

Is This Answer Correct ?    3 Yes 0 No

Post New Answer

More MySQL Interview Questions

What is the latest mysql version?

0 Answers  


Does mysql support sequence?

0 Answers  


Query to select passwords from a table having a column "Password" Whose length is b/w 8 &15 and having 'A' as the first character in the password irrespective of case.

3 Answers  


Is mysql a framework?

0 Answers  


How do you backup a database in mysql?

0 Answers  


What is mysql community edition?

0 Answers  


How to update a root password.

0 Answers  


What is a blob datatype?

0 Answers  


How do I start mysql?

0 Answers  


Table A has 5 rows and table B has 0 rows Cartesian join on A,B will have----rows

2 Answers  


How many rows mysql can handle?

0 Answers  


How do you shutdown a mysql database?

0 Answers  


Categories