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

How do I connect to mysql database?

0 Answers  


What is query design?

0 Answers  


What does mysql_fetch_assoc do?

0 Answers  


What could be the reason that the mysql statement 'select avg (salary) from emp' generates an inaccurate output?

0 Answers  


How do I restore a mysql database?

0 Answers  






How do I run mysql from command line?

0 Answers  


How do you flush privileges?

0 Answers  


How to display top 50 rows?

0 Answers  


What is mysql protocol?

0 Answers  


mazimum size of a database in mysql? when we create a table then how many tables actually created? write there name?

1 Answers  


Can you tell how many values can set the function of mysql to consider?

0 Answers  


Is oracle mysql free?

0 Answers  


Categories