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 difference between char and varchar in mysql?

0 Answers  


How do I edit a trigger in mysql?

0 Answers  


How you will show all data from a table.

0 Answers  


Does mysql support nosql?

0 Answers  


please give me the answer for this: query which generates the second highest integer in the table?

8 Answers  






What is offset limit?

0 Answers  


What are ddl statements in mysql?

0 Answers  


What are the disadvantages of mysql?

0 Answers  


What is diff b/w MYISAM and INNODB storage engine. and also define the benifits and drawbacks of both storage engine

1 Answers  


How can we change the name of a column of a table?

7 Answers  


What is dbms in mysql?

0 Answers  


How to rename an existing table in mysql?

0 Answers  


Categories