How to resolve the algorithm Table creation/Postal addresses step by step in the Sidef programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Table creation/Postal addresses step by step in the Sidef programming language

Table of Contents

Problem Statement

Create a table to store addresses. You may assume that all the addresses to be stored will be located in the USA.   As such, you will need (in addition to a field holding a unique identifier) a field holding the street address, a field holding the city, a field holding the state code, and a field holding the zipcode.   Choose appropriate types for each field. For non-database languages, show how you would open a connection to a database (your choice of which) and create an address table in it. You should follow the existing models here for how you would structure the table.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Table creation/Postal addresses step by step in the Sidef programming language

Source code in the sidef programming language

require('DBI');

var db = %s'DBI'.connect('DBI:mysql:database:server','login','password');

var statment = <<'EOF';
CREATE TABLE `Address` (
    `addrID`       int(11)     NOT NULL   auto_increment,
    `addrStreet`   varchar(50) NOT NULL   default '',
    `addrCity`     varchar(25) NOT NULL   default '',
    `addrState`    char(2)     NOT NULL   default '',
    `addrZIP`      char(10)    NOT NULL   default '',
    PRIMARY KEY (`addrID`)
);
EOF

var exec = db.prepare(statment);
exec.execute;


  

You may also check:How to resolve the algorithm Hilbert curve step by step in the Go programming language
You may also check:How to resolve the algorithm FizzBuzz step by step in the Factor programming language
You may also check:How to resolve the algorithm Compound data type step by step in the Common Lisp programming language
You may also check:How to resolve the algorithm Lucky and even lucky numbers step by step in the REXX programming language
You may also check:How to resolve the algorithm Define a primitive data type step by step in the Ada programming language